/* ==========================================================================
   style.css
   Shared components from the portfolio (header, footer, buttons, layout)
   plus the calculator itself. Tokens and the reset live in base.css.
   ========================================================================== */

/* Extra tokens for result states (the portfolio has no success or error colours) */
:root {
  --success: #1f6b3a;
  --success-soft: #e8f4ec;
  --danger: #a3261c;
  --danger-soft: #fbeceb;
}

:root[data-theme='dark'] {
  --success: #7fd199;
  --success-soft: #16261c;
  --danger: #f08a80;
  --danger-soft: #2e1a18;
}

/* Inter, self-hosted (variable font, latin subset, SIL Open Font License) --- */

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('../fonts/inter-latin-variable.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* Inline SVG icons (sprite at the top of index.html) ----------------------- */

.icon {
  display: block;
  flex: none;
  width: 1em;
  height: 1em;
  fill: currentColor;
}

/* Lenis smooth scroll (matches lenis@1.3.26) ------------------------------ */

html.lenis,
html.lenis body {
  height: auto;
}

/* base.css turns on native smooth scrolling. Lenis does the smoothing itself,
   so native smoothing must be off or the two fight each other. */
html.lenis.lenis-smooth {
  scroll-behavior: auto !important;
}

.lenis:not(.lenis-autoToggle).lenis-stopped {
  overflow: clip;
}

.lenis [data-lenis-prevent],
.lenis [data-lenis-prevent-wheel],
.lenis [data-lenis-prevent-touch],
.lenis [data-lenis-prevent-vertical],
.lenis [data-lenis-prevent-horizontal] {
  overscroll-behavior: contain;
}

.lenis.lenis-smooth iframe {
  pointer-events: none;
}

/* Sections receive focus after an in-page link; they do not need a ring. */
[tabindex='-1']:focus {
  outline: none;
}

/* Layout ----------------------------------------------------------------- */

.container {
  width: min(var(--container), 100% - var(--gutter) * 2);
  margin-inline: auto;
}

.section {
  padding-block: var(--section-space);
}

.section--tint {
  background: var(--surface-2);
}

.section-head {
  display: grid;
  gap: 0.75rem;
  max-width: 62ch;
  margin-bottom: clamp(2rem, 5vw, 3.25rem);
}

.eyebrow {
  margin: 0;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.lead {
  max-width: 62ch;
  color: var(--text-muted);
  font-size: clamp(1.05rem, 1.5vw, 1.2rem);
  line-height: 1.65;
}

.page-header {
  padding-block: clamp(2.5rem, 7vw, 4.5rem) clamp(1.75rem, 4vw, 2.75rem);
  border-bottom: 1px solid var(--line);
}

.page-header .container {
  display: grid;
  gap: 1rem;
}

.page-header h1 {
  max-width: none;
}

.prose {
  display: grid;
  gap: 1rem;
  max-width: 62ch;
  color: var(--text-muted);
}

.prose strong {
  color: var(--text);
}

.note {
  padding: 0.8rem 1rem;
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.93rem;
}

.formula {
  padding: 0.9rem 1.1rem;
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
}

/* Buttons ---------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  min-height: 44px;
  padding: 0.7rem 1.3rem;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.btn-secondary {
  border-color: var(--line-strong);
  background: transparent;
  color: var(--text);
}

.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Header ----------------------------------------------------------------- */

/* The header is a floating, rounded, slightly see-through bar. The wrapper is
   invisible and lets clicks through; only the bar itself catches them. */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  padding-top: 0.75rem;
  pointer-events: none;
}

.header-row {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  width: min(100% - 1.5rem, var(--container));
  max-width: none;
  min-height: 60px;
  padding: 0.4rem 0.6rem 0.4rem 1.5rem;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  backdrop-filter: blur(14px) saturate(1.4);
  box-shadow: 0 4px 20px rgba(22, 20, 15, 0.05);
  pointer-events: auto;
}

/* A full pill whenever the bar stays on one row. */
.js .header-row {
  border-radius: 999px;
}

@media (min-width: 721px) {
  .header-row {
    border-radius: 999px;
  }
}

.site-header.is-scrolled .header-row {
  box-shadow: 0 10px 30px rgba(22, 20, 15, 0.1);
}

:root[data-theme='dark'] .site-header.is-scrolled .header-row {
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

@media (prefers-reduced-motion: no-preference) {
  .header-row {
    transition: box-shadow 0.3s ease, background-color 0.3s ease, border-color 0.3s ease;
  }
}

.brand {
  color: var(--text);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.brand:hover {
  color: var(--accent);
}

.primary-nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.primary-nav a {
  display: inline-block;
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  color: var(--text-muted);
  font-size: 0.92rem;
  font-weight: 500;
  text-decoration: none;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.primary-nav a:hover {
  background: var(--accent-soft);
  color: var(--text);
}

.primary-nav a[aria-current='true'],
.primary-nav a[aria-current='page'] {
  background: var(--accent-soft);
  color: var(--accent);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.icon-btn {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  color: var(--text);
  line-height: 1;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color 0.2s ease, color 0.2s ease;
}

/* Font Awesome 7 icons are 1.25em wide by default. A square box is easier to centre. */
.icon-btn i {
  display: block;
  flex: none;
  width: 1em;
  height: 1em;
  font-size: 1rem;
  line-height: 1;
  text-align: center;
}

/* Hover colours only where a real pointer exists, so a tap on a phone does not leave them stuck. */
@media (hover: hover) {
  .icon-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
  }
}


/* Theme and menu buttons need JavaScript, so they stay hidden without it. */
.theme-toggle,
.nav-toggle {
  display: none;
}

.js .theme-toggle {
  display: inline-flex;
}

/* The crescent glyph sits left of its box, so nudge it to look centred. */
.theme-toggle .icon--moon {
  transform: translate(1.5px, -0.5px);
}

@media (min-width: 721px) {
  .primary-nav {
    margin-left: auto;
  }
}

@media (max-width: 720px) {
  .js .nav-toggle {
    display: inline-flex;
  }

  /* Without JavaScript the nav simply wraps onto a second row. */
  .primary-nav {
    order: 3;
    width: 100%;
    padding-bottom: 0.75rem;
  }

  /* The open menu is a rounded panel under the bar, kept solid so the page
     text behind it does not show through. */
  .js .primary-nav {
    display: none;
    position: absolute;
    top: calc(100% + 0.5rem);
    left: 0;
    right: 0;
    order: 0;
    width: auto;
    padding: 0.4rem 1.25rem 0.6rem;
    border: 1px solid var(--line);
    border-radius: 24px;
    background: var(--surface);
    box-shadow: 0 12px 32px rgba(22, 20, 15, 0.12);
  }

  .js .primary-nav.is-open {
    display: block;
  }

  .js .primary-nav ul {
    flex-direction: column;
    gap: 0;
  }

  .js .primary-nav a {
    display: block;
    padding: 0.85rem 0;
    border-bottom: 1px solid var(--line);
    border-radius: 0;
    font-size: 1.05rem;
  }

  .js .primary-nav a:hover,
  .js .primary-nav a[aria-current='true'],
  .js .primary-nav a[aria-current='page'] {
    background: none;
  }

  .js .primary-nav a[aria-current='true'],
  .js .primary-nav a[aria-current='page'] {
    color: var(--accent);
  }

  .js .primary-nav li:last-child a {
    border-bottom: 0;
  }
}

/* Calculator ------------------------------------------------------------- */

.section--calc {
  padding-block: clamp(2rem, 5vw, 3.25rem) var(--section-space);
}

.calc-layout {
  display: block;
}

.calc-layout .result {
  margin-top: 1.5rem;
}

@media (min-width: 960px) {
  .calc-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    align-items: start;
    gap: 2rem;
  }

  .calc-layout .result {
    margin-top: 0;
  }
}

.noscript {
  margin-bottom: 1.5rem;
  padding: 1rem 1.25rem;
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  background: var(--danger-soft);
}

.subject-grid {
  display: grid;
  gap: 1rem;
}

@media (min-width: 640px) {
  .subject-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.subject {
  position: relative;
  min-width: 0;
  margin: 0;
  padding: 1.1rem 1.25rem 1.25rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.subject:focus-within {
  border-color: var(--line-strong);
  box-shadow: var(--shadow);
}

.subject.is-complete {
  border-color: color-mix(in srgb, var(--success) 50%, var(--line));
}

.subject.is-ng {
  border-color: var(--danger);
}

/* Tick shown once both parts of a subject are graded. */
.subject.is-complete::after {
  content: '\2713';
  content: '\2713' / '';
  position: absolute;
  top: 1rem;
  right: 1rem;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--success-soft);
  color: var(--success);
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1;
}

.subject legend {
  float: left;
  width: 100%;
  margin: 0 0 0.85rem;
  padding: 0 2.25rem 0 0;
  font-weight: 600;
  line-height: 1.3;
}

.subject legend + * {
  clear: both;
}

.subject .credits {
  display: block;
  margin-top: 0.15rem;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 400;
}

.subject-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.field label {
  display: block;
  margin-bottom: 0.3rem;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 500;
}

.field select {
  width: 100%;
  min-height: 44px;
  padding: 0.5rem 2rem 0.5rem 0.75rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background-color: var(--surface-2);
  background-image:
    linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
    linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.field select:hover {
  border-color: var(--accent);
}

.field select.is-set {
  border-color: var(--accent);
  background-color: var(--accent-soft);
  font-weight: 600;
}

.subject-error,
.subject-ng,
.subject-lock {
  display: none;
  margin-top: 0.7rem;
  color: var(--danger);
  font-size: 0.85rem;
}

.subject-lock {
  color: var(--text-muted);
}

/* Subjects beyond the 6 a student studies are locked until one is cleared. */
.subject.is-locked {
  background: var(--surface-2);
}

.subject.is-locked legend,
.subject.is-locked .subject-fields {
  opacity: 0.55;
}

.subject.is-locked .subject-lock {
  display: block;
}

.field select:disabled {
  cursor: not-allowed;
}

.field select:disabled:hover {
  border-color: var(--line-strong);
}

/* Clear button sits on the credit-hours line, only once a subject is started. */
.subject-clear {
  display: none;
  position: absolute;
  top: 2.5rem;
  right: 1rem;
  min-width: 44px;
  min-height: 28px;
  padding: 0.1rem 0.5rem;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.subject-clear:hover {
  color: var(--accent-hover);
}

.subject.is-active .subject-clear {
  display: inline-block;
}

.subject.is-incomplete .subject-error {
  display: block;
}

.subject.is-ng:not(.is-incomplete) .subject-ng {
  display: block;
}

/* Result panel ----------------------------------------------------------- */

.result {
  padding: 1.25rem 1.4rem 1.4rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

@media (min-width: 960px) {
  .result {
    position: sticky;
    top: calc(var(--header-h) + 1rem);
  }
}

.result-label {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.result-main {
  display: flex;
  align-items: baseline;
  gap: 0.9rem;
  margin-top: 0.25rem;
}

.result-gpa {
  font-size: clamp(2.2rem, 8vw, 3.4rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.result-grade {
  padding: 0.15rem 0.7rem;
  border-radius: 999px;
  background: var(--success-soft);
  color: var(--success);
  font-size: 1.05rem;
  font-weight: 700;
}

.result-grade:empty {
  display: none;
}

.result-message {
  margin-top: 0.75rem;
  color: var(--text-muted);
  font-size: 0.92rem;
}

.progress {
  height: 6px;
  margin-top: 1.1rem;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--line);
}

.progress-bar {
  display: block;
  width: calc(var(--progress, 0) * 100%);
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 0.3s ease, background-color 0.2s ease;
}

.result-meta {
  margin-top: 0.5rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

.result-reset {
  width: 100%;
  margin-top: 1rem;
}

.result[data-state='idle'] .result-gpa,
.result[data-state='progress'] .result-gpa {
  color: var(--text-muted);
}

.result[data-state='done'] {
  border-color: color-mix(in srgb, var(--success) 50%, var(--line-strong));
}

.result[data-state='done'] .progress-bar {
  background: var(--success);
}

.result[data-state='ng'] {
  border-color: var(--danger);
}

.result[data-state='ng'] .result-gpa,
.result[data-state='ng'] .result-message {
  color: var(--danger);
}

.result[data-state='ng'] .progress-bar {
  background: var(--danger);
}

/* On small screens the panel is a compact bar pinned to the bottom. */
@media (max-width: 959px) {
  .result {
    position: sticky;
    bottom: 0.75rem;
    z-index: 20;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      'live reset'
      'bar bar'
      'meta meta';
    align-items: center;
    gap: 0.5rem 1rem;
    padding: 0.85rem 1rem;
    box-shadow: 0 10px 30px rgba(22, 20, 15, 0.18);
  }

  .result-label {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .result-live {
    grid-area: live;
  }

  .result-main {
    margin-top: 0;
  }

  .result-message {
    margin-top: 0.4rem;
    font-size: 0.85rem;
  }

  .result-reset {
    grid-area: reset;
    width: auto;
    margin: 0;
    padding-inline: 1rem;
  }

  .progress {
    grid-area: bar;
    margin: 0;
  }

  .result-meta {
    grid-area: meta;
    margin: 0;
  }
}

/* Reference tables ------------------------------------------------------- */

.ref-block {
  display: grid;
  gap: 1rem;
}

.ref-block + .ref-block,
.ref-block + .split {
  margin-top: clamp(2.5rem, 6vw, 4rem);
}

.split {
  display: grid;
  gap: clamp(2rem, 5vw, 3rem);
}

@media (min-width: 900px) {
  .split {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
}

.data-table th,
.data-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

.data-table thead th {
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.data-table tbody th {
  color: var(--text);
  font-weight: 700;
}

.data-table tbody tr:last-child > * {
  border-bottom: 0;
}

.data-table .point {
  font-weight: 600;
}

.data-table .is-ng > * {
  color: var(--danger);
}

/* FAQ -------------------------------------------------------------------- */

.faq {
  max-width: 70ch;
}

.faq details {
  border-top: 1px solid var(--line);
}

.faq details:last-child {
  border-bottom: 1px solid var(--line);
}

.faq summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem 0;
  font-weight: 600;
  list-style: none;
  cursor: pointer;
}

.faq summary::-webkit-details-marker {
  display: none;
}

.faq summary::after {
  content: '+';
  content: '+' / '';
  flex: none;
  color: var(--accent);
  font-size: 1.4rem;
  font-weight: 400;
  line-height: 1;
}

.faq details[open] summary::after {
  content: '\2212';
  content: '\2212' / '';
}

.faq details p {
  padding-bottom: 1.1rem;
  color: var(--text-muted);
}

/* Footer ----------------------------------------------------------------- */

.site-footer {
  border-top: 1px solid var(--line);
  background: var(--surface-2);
}

.footer-main {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 2.5rem;
  padding-block: clamp(2.5rem, 6vw, 4rem);
}

.footer-about p {
  margin-top: 0.75rem;
  max-width: 38ch;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.footer-title {
  margin: 0 0 0.85rem;
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.footer-links {
  display: grid;
  gap: 0.35rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.footer-links a {
  display: inline-block;
  padding: 0.15rem 0;
  color: var(--text-muted);
  font-size: 0.95rem;
  text-decoration: none;
}

.footer-links a:hover {
  color: var(--accent);
}

.social-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.social-row a {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  color: var(--text);
  font-size: 1.05rem;
  text-decoration: none;
  transition: border-color 0.2s ease, color 0.2s ease, background-color 0.2s ease;
}

.social-row a:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.footer-mail {
  margin-top: 1rem;
  font-size: 0.95rem;
}

.footer-mail a {
  color: var(--text);
}

.footer-mail a:hover {
  color: var(--accent);
}

.footer-base {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  padding-block: 1.25rem;
  border-top: 1px solid var(--line);
  color: var(--text-muted);
  font-size: 0.88rem;
}

.footer-base a {
  color: var(--text-muted);
}

.footer-base a:hover {
  color: var(--accent);
}

@media (max-width: 820px) {
  .footer-main {
    grid-template-columns: 1fr 1fr;
  }

  .footer-about {
    grid-column: 1 / -1;
  }
}

@media (max-width: 520px) {
  .footer-main {
    grid-template-columns: 1fr;
    gap: 2rem;
  }
}
