:root {
  color-scheme: light;

  /* Surfaces */
  --hy-bg: #FFFCF0;
  --hy-panel: #F2F0E5;

  /* Text — warm ink (from B) */
  --hy-text: #4C4639;        /* body */
  --hy-heading: #35322A;     /* headings */

  /* Structure — hairlines (from C) */
  --hy-border: #DAD8CE;      /* base-150 */

  /* Links */
  --hy-link: #736B58;
  --hy-link-underline: #C2BBA6;

  /* Tertiary accent */
  --hy-accent: #C15F3C;      /* terracotta */
  --hy-accent-soft: rgba(193, 95, 60, 0.14);

  /* Inline code */
  --hy-code-bg: #F2F0E5;
  --hy-code-text: #8A5A3F;
  --hy-code-border: #DAD8CE;

  /* Social SVG icon tint (near-black source -> muted warm gray-brown) */
  --hy-icon-filter: invert(45%) sepia(9%) saturate(560%) hue-rotate(9deg) brightness(95%);

  --hy-font: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
  --hy-font-mono: ui-monospace, "SF Mono", "Cascadia Code", "Roboto Mono",
    Menlo, Consolas, monospace;
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --hy-bg: #262624;
  --hy-panel: #30302C;

  --hy-text: #BFBCB0;
  --hy-heading: #E3E1D7;

  --hy-border: #3E3D38;

  --hy-link: #A19C8C;
  --hy-link-underline: #56534A;

  --hy-accent: #D97757;
  --hy-accent-soft: rgba(217, 119, 87, 0.18);

  --hy-code-bg: #33322E;
  --hy-code-text: #C98A6B;
  --hy-code-border: #45443E;

  --hy-icon-filter: invert(68%) sepia(8%) saturate(320%) hue-rotate(9deg) brightness(96%);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;

    --hy-bg: #262624;
    --hy-panel: #30302C;

    --hy-text: #BFBCB0;
    --hy-heading: #E3E1D7;

    --hy-border: #3E3D38;

    --hy-link: #A19C8C;
    --hy-link-underline: #56534A;

    --hy-accent: #D97757;
    --hy-accent-soft: rgba(217, 119, 87, 0.18);

    --hy-code-bg: #33322E;
    --hy-code-text: #C98A6B;
    --hy-code-border: #45443E;

    --hy-icon-filter: invert(68%) sepia(8%) saturate(320%) hue-rotate(9deg) brightness(96%);
  }
}

/* --------------------------------------------------------------------------
   Global
   -------------------------------------------------------------------------- */
@media screen {
  body {
    background-color: var(--hy-bg);
    color: var(--hy-text);
    font-family: var(--hy-font);
    font-size: 16px;
    line-height: 1.65;
    font-weight: 400;
  }

  h1, h2, h3, h4, h5, h6,
  body h1, body h2, body h3, body h4, body h5, body h6 {
    font-family: var(--hy-font);
    color: var(--hy-heading);
    font-weight: 600;
    letter-spacing: -0.015em;
  }

  /* Links */
  a {
    color: var(--hy-link);
    text-decoration: underline;
    text-decoration-color: var(--hy-link-underline);
    text-underline-offset: 3px;
    text-decoration-thickness: 1px;
  }
  a:hover, a:focus {
    color: var(--hy-accent);
    text-decoration-color: var(--hy-accent);
  }

  ::selection {
    background-color: var(--hy-accent-soft);
  }
  :focus-visible {
    outline: 2px solid var(--hy-accent);
    outline-offset: 2px;
  }
}

/* Subtle color transitions */
@media screen and (prefers-reduced-motion: no-preference) {
  a, .nav-link, .dropdown-item, .header-icon {
    transition: color 150ms ease, background-color 150ms ease,
      text-decoration-color 150ms ease, filter 150ms ease, opacity 150ms ease;
  }
}

/* --------------------------------------------------------------------------
   Home page (index.html) — Bootstrap 5, main.css
   -------------------------------------------------------------------------- */
@media screen {
  header {
    border-bottom: 1px solid var(--hy-border);
  }

  /* Navbar links */
  .navbar-light .navbar-nav .nav-link {
    color: var(--hy-text);
    text-decoration: none;
  }
  .navbar-light .navbar-nav .nav-link:hover,
  .navbar-light .navbar-nav .nav-link:focus,
  .navbar-light .navbar-nav .nav-link.show {
    color: var(--hy-accent);
  }

  /* Bootstrap dropdown */
  .dropdown-menu {
    background-color: var(--hy-panel);
    border: 1px solid var(--hy-border);
    box-shadow: 0 6px 18px rgba(53, 50, 42, 0.12);
  }
  .dropdown-item {
    color: var(--hy-text);
    text-decoration: none;
  }
  .dropdown-item:hover,
  .dropdown-item:focus,
  .dropdown-item:active {
    background-color: var(--hy-accent-soft);
    color: var(--hy-accent);
  }

  /* Brand */
  a#brand {
    font-family: var(--hy-font);
    color: var(--hy-heading);
    font-weight: 500;
    text-decoration: none;
  }
  a#brand:hover {
    color: var(--hy-accent);
  }

  /* Sidebar */
  #sidebar small,
  #namecard small {
    color: var(--hy-link);
  }

  /* Home body */
  #home-body {
    max-width: 68ch;
  }

  /* h2: not too big, */
  #home-body h2 {
    font-size: 1.6rem;
    margin-bottom: 0.5rem;
    position: relative;
    padding-left: 0.65rem;
  }
  /* h2: adds left terracotta marker bar */
  #home-body h2::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0.18em;
    bottom: 0.18em;
    width: 3px;
    border-radius: 2px;
    background-color: var(--hy-accent);
  }

  /* Terracotta markers prefixes/spans */
  #home-body ul li > strong,
  #home-body ul li > span > strong,
  #home-body ul li > strong > span {
    color: var(--hy-accent);
    font-weight: 600;
  }

  /* Inline code */
  p > code, li > code, code {
    background-color: var(--hy-code-bg);
    color: var(--hy-code-text);
    border: 1px solid var(--hy-code-border);
    border-radius: 4px;
    padding: 0.05em 0.35em;
    font-family: var(--hy-font-mono);
    font-size: 0.9em;
  }

  /* Footer */
  footer hr {
    border: none;
    border-top: 1px solid var(--hy-border);
    color: var(--hy-border);
    background-color: transparent;
    opacity: 1;
  }
  footer small {
    color: var(--hy-link);
  }

  /* Social SVG icons */
  .header-icon {
    filter: var(--hy-icon-filter);
    opacity: 0.85;
  }
  .social-link:hover .header-icon,
  .social-link:focus .header-icon {
    opacity: 1;
  }
}

/* --------------------------------------------------------------------------
   CV page
   -------------------------------------------------------------------------- */
@media screen {
  body.container-fluid {
    background-color: var(--hy-bg);
    color: var(--hy-text);
    font-family: var(--hy-font);
    line-height: 1.65;
  }

  body.container-fluid h1,
  body.container-fluid h2,
  body.container-fluid h3,
  body.container-fluid h4,
  body.container-fluid h5,
  body.container-fluid h6 {
    font-family: var(--hy-font);
    color: var(--hy-heading);
    font-weight: 600;
    letter-spacing: -0.015em;
  }

  body.container-fluid #name {
    font-weight: 600;
  }
  body.container-fluid #contact {
    color: var(--hy-link);
  }

  body.container-fluid .section {
    margin-top: 1.5em;
  }
  body.container-fluid .section:not(:last-of-type) {
    margin-bottom: 2em;
  }
  body.container-fluid .section h1 {
    font-size: 1.35rem;
    font-weight: 600;
    margin-bottom: 0.35rem;
  }

  body.container-fluid hr {
    border: none;
    height: 1px;
    background-color: var(--hy-border);
    color: var(--hy-border);
    margin-top: 0;
    margin-bottom: 0.75em;
  }

  body.container-fluid .position {
    color: var(--hy-heading);
  }
  body.container-fluid .company {
    color: var(--hy-link);
  }

  body.container-fluid a {
    color: var(--hy-link);
    text-decoration: underline;
    text-decoration-color: var(--hy-link-underline);
    text-underline-offset: 3px;
    text-decoration-thickness: 1px;
  }
  body.container-fluid a:hover,
  body.container-fluid a:focus {
    color: var(--hy-accent);
    text-decoration-color: var(--hy-accent);
  }

  body.container-fluid #publication-list li {
    padding-bottom: 0.6em;
  }
}

/* --------------------------------------------------------------------------
   Theme toggle — light / system / dark segmented control.
   Rendered by _includes/theme-toggle.html; behavior in
   static/js/theme-toggle.js. Active state may use the tertiary accent.
   -------------------------------------------------------------------------- */
@media screen {
  .theme-toggle {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 3px;
    background-color: var(--hy-panel);
    border: 1px solid var(--hy-border);
    border-radius: 999px;
  }
  .theme-toggle button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: none;
    border-radius: 999px;
    background-color: transparent;
    color: var(--hy-link);
    cursor: pointer;
  }
  .theme-toggle button:hover {
    color: var(--hy-accent);
  }
  .theme-toggle button.is-active {
    background-color: var(--hy-bg);
    color: var(--hy-accent);
    box-shadow: 0 1px 2px rgba(53, 50, 42, 0.10);
  }
  .theme-toggle svg {
    width: 15px;
    height: 15px;
    display: block;
  }

  /* Placement: home navbar (absolute right, doesn't shift centered links) */
  .navbar {
    position: relative;
  }
  .navbar-theme-toggle {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
  }

  /* Placement: CV page (fixed top-right; the CV has no navbar) */
  .cv-theme-toggle {
    position: fixed;
    top: 0.9rem;
    right: 0.9rem;
    z-index: 100;
  }
}

/* Print safety: theme never bleeds into print output. */
@media print {
  body,
  body.container-fluid {
    background-color: transparent;
    color: #3D3D3D;
  }
  a {
    color: #3D3D3D;
    text-decoration: none;
  }
  .header-icon {
    filter: none;
    opacity: 1;
  }
  .theme-toggle,
  .navbar-theme-toggle,
  .cv-theme-toggle {
    display: none !important;
  }
}
