/*
 * Visual polish based on the latest design review screenshots.
 * Kept separate from the main stylesheets so the changes stay easy to revert.
 */

/* Hero copy: remove the artificial bold-first-line treatment. */
.hero-intro {
  max-width: 780px;
  color: #4f4f4b;
  font-weight: 400;
}

.hero-intro::first-line {
  color: inherit;
  font-weight: inherit;
}

/* Keep the short labels visually consistent and properly capitalized. */
.quick-facts span,
.stat-card span {
  text-transform: none;
}

/*
 * Section headings: align the explanatory copy with the first line of the title
 * instead of letting it sit near the bottom of a two-line heading.
 */
@media (min-width: 901px) {
  .section-heading {
    align-items: start;
  }

  .section-heading > p {
    align-self: start;
    margin-top: 2.75rem;
  }

  .skills-section .section-heading-actions {
    align-self: start;
    display: grid;
    justify-items: end;
    gap: .9rem;
    padding-top: 2.75rem;
  }

  .skills-section .section-heading-actions > p {
    max-width: 420px;
    text-align: right;
  }

  /* Keep the skill description on one line on large screens. */
  .skill-panel > p {
    max-width: none;
  }
}

@media (min-width: 1180px) {
  .skill-panel > p {
    white-space: nowrap;
    font-size: 1.02rem;
  }
}

/* Project cards: align content starts and remove unnecessary vertical voids. */
.project-featured {
  min-height: 0;
  align-items: start;
  align-content: start;
  padding-block: clamp(1.7rem, 2.5vw, 2.2rem);
}

.project-featured .terminal-art {
  align-self: center;
}

.project-card:not(.project-featured) {
  min-height: 360px;
  align-content: stretch;
  grid-template-rows: auto auto 1fr;
}

.project-card:not(.project-featured) .project-body {
  margin-top: 1.45rem;
}

.project-card:not(.project-featured) .project-body h3 {
  margin-top: 0;
}

.project-card:not(.project-featured) > .terminal-art,
.project-card:not(.project-featured) > .paf-art,
.project-card:not(.project-featured) > .cert-art,
.project-card:not(.project-featured) > .enigma-art,
.project-card:not(.project-featured) > .omnidev-art,
.project-card:not(.project-featured) > .project-glyph {
  align-self: end;
}

.project-card:not(.project-featured) .project-logos {
  margin-top: 1.4rem;
  margin-bottom: 1.2rem;
}

/* The first two side-by-side project cards should start their titles together. */
.project-list > .project-card:nth-child(2) .project-body,
.project-list > .project-card:nth-child(3) .project-body {
  margin-top: 1.45rem;
}

/* Final CTA: keep the kicker neutral and make “avenir” the true accent. */
.contact-inner > .mono {
  color: #fff;
}

.contact-inner h2 span {
  color: var(--accent);
  font-family: inherit;
  font-weight: 650;
  -webkit-text-stroke: 0;
}

/* Preserve the existing mobile layout and let text wrap naturally again. */
@media (max-width: 900px) {
  .section-heading > p {
    margin-top: 0;
  }

  .skills-section .section-heading-actions {
    padding-top: 0;
  }

  .project-featured {
    min-height: 0;
  }

  .project-card:not(.project-featured) {
    min-height: 0;
    grid-template-rows: auto;
  }

  .project-card:not(.project-featured) .project-body {
    margin-top: 0;
  }
}

/* Unified rhythm and project visuals. */
:root { --project-art-surface: #eeede8; }
.section { padding-block: clamp(5.5rem, 9vw, 9rem); }
.projects-section, .lab-section { border-top: 1px solid var(--line); }
.project-list, .stats-grid, .certifications-grid { gap: clamp(1rem, 1.6vw, 1.35rem); }
.project-card:not(.project-featured) {
  min-height: 410px;
  grid-template-rows: auto 1fr 160px;
  row-gap: 1.25rem;
}
.project-list > .project-card:not(.project-featured) .project-body {
  margin-top: 0;
}
.project-card:not(.project-featured) .project-logos {
  margin-top: 1.1rem;
  margin-bottom: 0;
}
.project-card:not(.project-featured) > :is(.terminal-art, .paf-art, .cert-art, .enigma-art, .omnidev-art, .project-glyph) {
  place-self: stretch;
  width: 100%;
  height: 160px;
  min-height: 0;
  margin-top: 0;
  padding: 1rem;
  aspect-ratio: auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--project-art-surface);
  box-shadow: none;
}
.project-card:not(.project-featured) > .terminal-art { justify-content: center; }
.project-card:not(.project-featured) > :is(.paf-art, .enigma-art, .omnidev-art) img {
  width: auto;
  height: 128px;
  max-width: 100%;
  object-fit: contain;
}
.project-card:not(.project-featured) > .cert-art::before {
  right: 1rem;
  bottom: 1rem;
  width: 50px;
  height: 50px;
}

/* Restrained interactions and a visible keyboard focus. */
:where(a, button, input, summary):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
@media (hover: hover) and (pointer: fine) {
  .project-card:hover, .certification-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 14px 32px rgba(10, 10, 10, .11);
  }
  .project-logos img:hover, .button:hover { transform: translateY(-1px); }
}

/* Consistent charcoal surfaces with one warm accent. */
html[data-theme="dark"] {
  --paper: #121313;
  --panel: #1d1e1e;
  --panel-2: #292a2a;
  --line: #444747;
  --muted: #b4b5b1;
  --accent: #ff866c;
  --accent-2: #ff866c;
  --project-art-surface: #292a2a;
}
html[data-theme="dark"] :is(.skills-section, .github-section) { background: #181a1a; }
html[data-theme="dark"] .project-featured,
html[data-theme="dark"] .certification-toeic { background: #101111; }
html[data-theme="dark"] .stat-card-accent {
  background: #2b211f;
  border-color: #905b4f;
}
html[data-theme="dark"] .stat-card-accent :is(strong, span, small) { color: #f2f2f2; }
html[data-theme="dark"] :is(.button-primary, .contact-section .button-primary) {
  background: var(--accent);
  color: #171717;
}
html[data-theme="dark"] .project-card:not(.project-featured) .project-logos img {
  filter: grayscale(1) brightness(0) invert(1);
  opacity: .72;
}
@media (hover: hover) and (pointer: fine) {
  html[data-theme="dark"] .project-card:hover,
  html[data-theme="dark"] .certification-card:hover {
    box-shadow: 0 14px 32px rgba(0, 0, 0, .3);
  }
}

@media (max-width: 900px) {
  .project-card:not(.project-featured) {
    min-height: 0;
    grid-template-rows: auto auto 140px;
  }
  .project-card:not(.project-featured) > :is(.terminal-art, .paf-art, .cert-art, .enigma-art, .omnidev-art, .project-glyph) {
    height: 140px;
  }
  .project-card:not(.project-featured) > :is(.paf-art, .enigma-art, .omnidev-art) img {
    height: 108px;
  }
}
@media (max-width: 700px) {
  .goupille-widget { right: .4rem; bottom: .45rem; width: 86px; }
  .goupille-button { width: 72px; }
  .goupille-blanket { width: 76px; height: 38px; bottom: 1.15rem; }
  .goupille-caption { display: none; }
  .goupille-bubble {
    bottom: 5.35rem;
    max-width: 150px;
    transform: translate(calc(-50% - 3.25rem), 8px);
  }
  .goupille-widget.is-open .goupille-bubble {
    transform: translateX(calc(-50% - 3.25rem));
  }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal, .reveal.visible, .project-card, .certification-card,
  .project-logos img, .button, .theme-option, nav a {
    transition: none;
  }
  .project-card:hover, .certification-card:hover,
  .project-logos img:hover, .button:hover { transform: none; }
  .goupille-widget.is-petted img, .goupille-widget.is-stretched img {
    animation: none;
  }
}

/* Main icon navigation, aligned to the upper right. */
.site-header {
  width: fit-content;
  max-width: calc(100% - 1rem);
  top: .75rem;
  height: auto;
  gap: .65rem;
  margin: .75rem clamp(.5rem, 1.7vw, 1.6rem) .75rem auto;
  padding: 0;
  border: 0;
  background: transparent;
  backdrop-filter: none;
}

html[data-theme="dark"] .site-header { background: transparent; }

.site-header .theme-switch {
  flex-shrink: 0;
  margin: 0;
  background: color-mix(in srgb, var(--paper) 86%, transparent);
  backdrop-filter: blur(12px);
}

main section[id] { scroll-margin-top: 100px; }
.progress-rail {
  position: relative;
  z-index: 30;
  min-width: 0;
}

.progress-rail-nav {
  position: relative;
  top: auto;
  right: auto;
  left: auto;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: .6rem;
  padding: .48rem;
  border: 1px solid color-mix(in srgb, var(--line) 86%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--paper) 86%, transparent);
  box-shadow: 0 12px 30px rgba(10,10,10,.10);
  backdrop-filter: blur(12px);
}

.progress-rail-nav::before {
  position: absolute;
  z-index: -1;
  top: 50%;
  right: 1.1rem;
  left: 1.1rem;
  height: 1px;
  content: "";
  background: var(--line);
}

.progress-rail a {
  position: relative;
  display: grid;
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  padding: 0;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 50%;
  color: var(--muted);
  background: var(--paper);
  font: 600 .88rem/1 "DM Mono", monospace;
  text-decoration: none;
  transition: color .18s ease, background .18s ease, border-color .18s ease, transform .18s ease;
}

.progress-rail a::after {
  position: absolute;
  top: calc(100% + .7rem);
  left: 50%;
  padding: .35rem .55rem;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  background: var(--paper);
  box-shadow: 0 8px 18px rgba(10,10,10,.10);
  content: attr(data-label);
  font: 600 .67rem/1 "Manrope", sans-serif;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -5px);
  transition: opacity .18s ease, transform .18s ease;
  white-space: nowrap;
}

.progress-rail a:hover:not([aria-current="location"]),
.progress-rail a:focus-visible:not([aria-current="location"]) {
  z-index: 1;
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  color: var(--accent);
  background: var(--paper);
}

.progress-rail a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.progress-rail a:hover::after,
.progress-rail a:focus-visible::after {
  opacity: 1;
  transform: translate(-50%, 0);
}

.progress-rail a[aria-current="location"] {
  z-index: 1;
  border-color: var(--accent);
  color: var(--paper);
  background: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent);
}

.progress-rail-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

html[data-theme="dark"] .progress-rail-nav {
  box-shadow: 0 12px 30px rgba(0,0,0,.35);
}

.menu-glass-filters { position: absolute; pointer-events: none; }

/* Refraction follows the horizontal menu, including narrow desktop previews. */
@media (min-width: 701px) {
  .site-header {
    --nav-glass-tint: rgba(255, 255, 255, .06);
    --nav-glass-sheen: rgba(255, 255, 255, .12);
    --nav-glass-edge: rgba(255, 255, 255, .50);
    --nav-glass-highlight: rgba(255, 255, 255, .70);
    --nav-glass-shadow: rgba(20, 25, 30, .09);
    --nav-glass-control: rgba(255, 255, 255, .04);
    --nav-glass-hover: rgba(255, 255, 255, .22);
  }
  html[data-theme="dark"] .site-header {
    --nav-glass-tint: rgba(0, 0, 0, .10);
    --nav-glass-sheen: rgba(255, 255, 255, .08);
    --nav-glass-edge: rgba(255, 255, 255, .20);
    --nav-glass-highlight: rgba(255, 255, 255, .26);
    --nav-glass-shadow: rgba(0, 0, 0, .22);
    --nav-glass-control: rgba(255, 255, 255, .025);
    --nav-glass-hover: rgba(255, 255, 255, .10);
  }
  html .site-header :is(.progress-rail-nav, .theme-switch) {
    background: color-mix(in srgb, var(--paper) 92%, transparent);
    border-color: var(--nav-glass-edge);
    box-shadow:
      inset 0 0 2px 1px rgba(255, 255, 255, .35),
      inset 0 0 10px 4px rgba(255, 255, 255, .15),
      inset 0 4px 16px rgba(17, 17, 26, .05),
      inset 0 8px 24px rgba(17, 17, 26, .05),
      inset 0 6px 56px rgba(17, 17, 26, .05),
      0 8px 24px var(--nav-glass-shadow);
  }
  @supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    html .site-header :is(.progress-rail-nav, .theme-switch) {
      background:
        linear-gradient(135deg, var(--nav-glass-sheen), transparent 48%),
        var(--nav-glass-tint);
      -webkit-backdrop-filter: blur(3px) saturate(120%);
      backdrop-filter: blur(3px) saturate(120%);
    }
  }
  @supports (backdrop-filter: url("#menu-glass-refraction")) {
    html .site-header .progress-rail-nav {
      -webkit-backdrop-filter: url("#menu-glass-refraction") saturate(120%);
      backdrop-filter: url("#menu-glass-refraction") saturate(120%);
    }
    html .site-header .theme-switch {
      -webkit-backdrop-filter: url("#theme-glass-refraction") saturate(120%);
      backdrop-filter: url("#theme-glass-refraction") saturate(120%);
    }
  }
  .progress-rail-nav::before { display: none; }
  .progress-rail a:not([aria-current="location"]) {
    background: var(--nav-glass-control);
    color: var(--ink);
  }
  .progress-rail a:hover:not([aria-current="location"]),
  .progress-rail a:focus-visible:not([aria-current="location"]) {
    background: var(--nav-glass-hover);
    color: var(--accent);
    box-shadow: inset 0 1px 0 var(--nav-glass-highlight);
  }
  @media (prefers-reduced-transparency: reduce) {
    html .site-header :is(.progress-rail-nav, .theme-switch) {
      background: var(--paper);
      -webkit-backdrop-filter: none;
      backdrop-filter: none;
    }
  }
  @media (forced-colors: active) {
    html .site-header :is(.progress-rail-nav, .theme-switch) {
      background: Canvas;
      border-color: CanvasText;
      box-shadow: none;
      -webkit-backdrop-filter: none;
      backdrop-filter: none;
    }
  }
}

@media (max-width: 600px), (max-width: 900px) and (max-height: 500px) and (pointer: coarse) {
  .site-header {
    position: fixed;
    top: 8px;
    right: 8px;
    width: 25px;
    max-width: none;
    margin: 0;
  }
  .site-header .theme-switch {
    position: fixed;
    top: 8px;
    right: 8px;
    gap: 1px;
    padding: 1.5px;
    border-width: .5px;
  }
  .site-header .theme-option { width: 15px; height: 15px; }
  .site-header .theme-option svg { width: 8px; height: 8px; }
  .site-header .progress-rail {
    position: fixed;
    top: 32px;
    right: 8px;
    bottom: 8px;
    display: flex;
    align-items: center;
  }
  .progress-rail-nav {
    --rail-icon-size: 16px;
    --rail-spacing: 3.5px;
    display: grid;
    grid-template-columns: var(--rail-icon-size);
    gap: var(--rail-spacing);
    padding: var(--rail-spacing);
    border-width: 1px;
    max-height: 100%;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: none;
    border-radius: calc(var(--rail-icon-size) / 2 + var(--rail-spacing));
  }
  .progress-rail-nav::-webkit-scrollbar { display: none; }
  .progress-rail-nav::before,
  .progress-rail a::after { display: none; }
  .progress-rail a {
    position: relative;
    width: var(--rail-icon-size);
    height: var(--rail-icon-size);
    border-width: .5px;
  }
  .progress-rail a svg { width: 8px; height: 8px; }
  .progress-rail a:focus-visible { outline-width: 1px; outline-offset: 1px; }
  .progress-rail a[aria-current="location"] {
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 18%, transparent);
  }
  main section[id] { scroll-margin-top: 16px; }
  .skills-section { overflow-x: clip; }
  .goupille-widget { right: 46px; }
  .skill-panel { padding: 1rem; }
  .skill-panel-head { flex-wrap: wrap; gap: .75rem; }
  .skill-panel-head > div { flex: 1 1 100%; min-width: 0; }
  .skill-panel :is(h3, p) { overflow-wrap: anywhere; }
}

@media (max-width: 380px) {
  .stats-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .progress-rail a,
  .progress-rail a::after { transition: none; }
}

/* Keep the full desktop introduction within the first screen. */
@media (min-width: 901px) {
  .site-header {
    position: fixed;
    right: clamp(.5rem, 1.7vw, 1.6rem);
    margin: 0;
  }

  .hero {
    min-height: 100svh;
    padding-block: clamp(1rem, 3vh, 2rem);
  }

  .hero h1 {
    font-size: clamp(3.6rem, min(6.8vw, 13vh), 7.2rem);
  }

  .hero .identity-card {
    width: 100%;
    /* Preserve the portrait's 4 / 5.15 ratio and leave room for its details. */
    max-width: max(280px, calc((100svh - 12rem) * .7767));
    justify-self: end;
  }
}

@media (min-width: 901px) and (max-height: 700px) {
  .hero { padding-block: .75rem; }

  .hero h1 {
    font-size: clamp(3.3rem, min(6.8vw, 11vh), 6rem);
  }

  .hero-copy::before { margin-bottom: .8rem; }
  .hero-intro { margin-block: 1rem; }
  .hero .quick-facts { margin-top: 1rem; padding-top: 1rem; }
}
/* Goupille leaves after the final message, with a way to call him back. */
.goupille-widget {
  transition: transform .75s cubic-bezier(.4, 0, .7, 1), opacity .5s ease;
}
.goupille-widget.is-leaving {
  transform: translateX(calc(100% + 80px));
  opacity: 0;
  pointer-events: none;
}
.goupille-widget[hidden],
.goupille-recall[hidden] { display: none; }
.goupille-recall {
  position: fixed;
  z-index: 259;
  right: 0;
  bottom: 1.25rem;
  width: 28px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-right: 0;
  border-radius: 12px 0 0 12px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 4px 14px rgba(0, 0, 0, .12);
  cursor: pointer;
  font-size: 26px;
}
.goupille-recall:hover { color: var(--accent); }
@media (prefers-reduced-motion: reduce) {
  .goupille-widget { transition: none; }
}

/* Keep Goupille and his recall control on the desktop version only. */
@media (max-width: 700px), (max-width: 900px) and (max-height: 500px) and (pointer: coarse) {
  .goupille-widget,
  .goupille-recall { display: none; }
}

/* Show the complete headline immediately; only its final period blinks. */
.hero-type-title .hero-type-period {
  font: inherit;
  letter-spacing: inherit;
  -webkit-text-stroke: inherit;
  animation: hero-period-blink 1s step-end infinite;
}
@keyframes hero-period-blink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .hero-type-title .hero-type-period { animation: none; }
}

