/* ============================================================
   HN Metrology — Main Stylesheet
   Single stylesheet, CSS custom properties throughout.
   Mobile-first: base styles for mobile, media queries for wider.
   ============================================================ */


/* ============================================================
   1. CSS Variables
   ============================================================ */

:root {
  /* -- Colors -- */
  --color-primary:    #CC0000;   /* Brand red */
  --color-secondary:  #2800D7;   /* Blue */
  --color-accent:     #4D148C;   /* Purple */
  --color-text:       #111111;   /* Body text */
  --color-text-muted: #555555;   /* Secondary text */
  --color-bg:         #FFFFFF;   /* Page background */
  --color-surface:    #F4F4F4;   /* Cards, panels */
  --color-border:     #DDDDDD;   /* Dividers, subtle borders */
  --color-white:      #FFFFFF;

  /* -- Typography -- */
  --font-family: 'Segoe UI', system-ui, -apple-system, Helvetica, sans-serif;
  --font-size-sm:   0.875rem;   /*  14px */
  --font-size-base: 1rem;       /*  16px */
  --font-size-lg:   1.125rem;   /*  18px */
  --font-size-xl:   1.5rem;     /*  24px */
  --font-size-2xl:  2rem;       /*  32px */
  --font-weight-light:  300;
  --font-weight-normal: 400;
  --font-weight-bold:   600;
  --line-height: 1.6;

  /* -- Spacing -- */
  --space-1:   0.25rem;   /*   4px */
  --space-2:   0.5rem;    /*   8px */
  --space-3:   0.75rem;   /*  12px */
  --space-4:   1rem;      /*  16px */
  --space-6:   1.5rem;    /*  24px */
  --space-8:   2rem;      /*  32px */
  --space-12:  3rem;      /*  48px */
  --space-16:  4rem;      /*  64px */

  /* -- Layout -- */
  --container-max:     1100px;
  --container-padding: var(--space-6);

  /* -- Navigation -- */
  --nav-height: 64px;
}


/* ============================================================
   2. Reset & Base
   ============================================================ */

*, *::before, *::after {
  box-sizing: border-box;
}

body {
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-light);
  line-height: var(--line-height);
  color: var(--color-text);
  background-color: var(--color-bg);
  margin: 0;
  padding: 0;
}

/* Zero-specificity link base — prevents :visited color from bleeding
   into nav items and buttons. Class-based colors always win naturally. */
:where(a) {
  color: var(--color-secondary);
  text-decoration: none;
}

:where(a):hover {
  color: var(--color-primary);
  text-decoration: underline;
}

img {
  max-width: 100%;
  height: auto;
  border: none;
  display: block;
}


/* ============================================================
   3. Typography
   ============================================================ */

h1, h2, h3, h4, h5, h6 {
  font-weight: var(--font-weight-light);
  line-height: 1.25;
  margin-top: 0;
  margin-bottom: var(--space-4);
}

h1 { font-size: var(--font-size-2xl); }
h2 { font-size: var(--font-size-xl); }
h3 { font-size: var(--font-size-lg); }

p {
  margin-top: 0;
  margin-bottom: var(--space-4);
}

ul, ol {
  margin-top: 0;
  margin-bottom: var(--space-4);
  padding-left: var(--space-6);
}

li {
  margin-bottom: var(--space-1);
}


/* ============================================================
   4. Layout
   ============================================================ */

.container {
  max-width: var(--container-max);
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--container-padding);
  padding-right: var(--container-padding);
}

.site-main {
  min-height: calc(100vh - var(--nav-height) - 120px);
  padding: var(--space-8) 0;
}

/* Two-column layout: main content + sidebar */
.content-with-sidebar {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-8);
}

@media (min-width: 768px) {
  .content-with-sidebar {
    grid-template-columns: 1fr 180px;
  }
}

/* Floated images within prose content */
.img-left {
  float: left;
  margin-right: var(--space-6);
  margin-bottom: var(--space-4);
  max-width: 180px;
}

.img-right {
  float: right;
  margin-left: var(--space-6);
  margin-bottom: var(--space-4);
  max-width: 180px;
}

@media (max-width: 599px) {
  .img-left,
  .img-right {
    float: none;
    max-width: 100%;
    margin: 0 0 var(--space-4) 0;
  }
}

/* Clearfix for floated content */
.clearfix::after {
  content: '';
  display: block;
  clear: both;
}

/* Two-column intro layout: text left, image right */
.page-intro {
  display: flex;
  gap: var(--space-8);
  align-items: flex-start;
  margin-bottom: var(--space-6);
}

.page-intro-text { flex: 1; }

.page-intro-image {
  flex: 0 0 auto;
}

.page-intro-image img {
  display: block;
  height: auto;
  max-width: 100%;
}

@media (max-width: 599px) {
  .page-intro {
    flex-direction: column;
  }
}

/* Callout box — prominent inline note or purchase prompt */
.callout {
  border-left: 4px solid var(--color-primary);
  background: var(--color-surface);
  padding: var(--space-4) var(--space-6);
  margin: var(--space-6) 0;
  font-size: var(--font-size-base);
}

/* Responsive 16:9 video embed */
.video-embed {
  aspect-ratio: 16 / 9;
  max-width: 550px;
  margin: var(--space-6) auto;
  overflow: hidden;
}

.video-embed iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}


/* ============================================================
   5. Site Header & Navigation
   ============================================================ */

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--color-bg);
  border-bottom: 3px solid var(--color-primary);
  height: var(--nav-height);
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--nav-height);
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--container-padding);
}

/* Logo */
.nav-logo a {
  display: block;
  line-height: 0;    /* remove extra space below inline image */
}

.nav-logo img {
  height: 48px;
  width: auto;
}

/* Nav links — desktop */
.nav-links {
  display: flex;
  align-items: center;
  gap: var(--space-6);
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-links a {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-normal);
  color: var(--color-text);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding-bottom: var(--space-1);
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
  text-decoration: none;
}

/* External link (HN Proficiency) — shown in blue to signal it leaves the site */
.nav-external > a {
  color: var(--color-secondary);
}

.nav-external > a:hover {
  color: var(--color-primary);
}

/* Hamburger toggle button — hidden on wide screens */
.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: var(--space-2);
  width: 36px;
  height: 36px;
}

.nav-toggle span {
  display: block;
  width: 24px;
  height: 2px;
  background: var(--color-text);
  transition: 0.25s;
}

/* Mobile nav — collapses below 900px */
@media (max-width: 899px) {
  .nav-toggle {
    display: flex;
  }

  .nav-links {
    display: none;
    position: absolute;
    top: var(--nav-height);
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: flex-start;
    background: var(--color-bg);
    border-bottom: 3px solid var(--color-primary);
    padding: var(--space-4) var(--container-padding);
    gap: var(--space-3);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  }

  .nav-links.is-open {
    display: flex;
  }

  /* On mobile, active indicator switches to left border */
  .nav-links a {
    border-bottom: none;
    padding-bottom: 0;
    padding-left: var(--space-3);
    border-left: 3px solid transparent;
  }

  .nav-links a:hover,
  .nav-links a.active {
    border-bottom: none;
    border-left-color: var(--color-primary);
  }
}


/* ============================================================
   6. Footer
   ============================================================ */

.site-footer {
  background: var(--color-surface);
  border-top: 3px solid var(--color-primary);
  padding: var(--space-8) 0;
  margin-top: var(--space-16);
}

.footer-inner {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--container-padding);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-4);
}

.footer-copy {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  font-family: 'Courier New', monospace;
  margin: 0;
}

.footer-logo img {
  height: 48px;
  width: auto;
}


/* ============================================================
   7. Buttons
   ============================================================ */

.btn {
  display: inline-block;
  padding: var(--space-2) var(--space-6);
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-normal);
  text-align: center;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
}

.btn-primary {
  background: var(--color-primary);
  color: var(--color-white);
}

.btn-primary:hover {
  background: #a00000;
  color: var(--color-white);
  text-decoration: none;
}

.btn-secondary {
  background: var(--color-secondary);
  color: var(--color-white);
}

.btn-secondary:hover {
  background: #1a00a0;
  color: var(--color-white);
  text-decoration: none;
}


/* ============================================================
   8. Homepage Hero
   ============================================================ */

.hero {
  padding: var(--space-12) 0 var(--space-8);
  border-bottom: 1px solid var(--color-border);
  margin-bottom: var(--space-4);
}

.hero-inner {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-8);
  align-items: center;
}

@media (min-width: 768px) {
  .hero-inner {
    grid-template-columns: 1fr 200px;
  }
}

.hero-text p {
  font-size: var(--font-size-lg);
  line-height: 1.7;
  margin-bottom: 0;
}

.hero-photo img {
  width: 100%;
  max-width: 200px;
  display: block;
  margin: 0 auto;
}

@media (max-width: 767px) {
  /* Hide photo on mobile — keeps hero clean on small screens */
  .hero-photo {
    display: none;
  }
}


/* ============================================================
   9a. Definition Lists
   Used on the About page for work history and ISO timelines.
   ============================================================ */

dl {
  margin-top: 0;
  margin-bottom: var(--space-4);
}

dt {
  font-weight: var(--font-weight-normal);
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: var(--space-4);
  margin-bottom: var(--space-1);
}

dd {
  margin-left: var(--space-6);
  margin-bottom: 0;
}


/* ============================================================
   9b. Papers Page
   Compact paper list grouped by topic category.
   ============================================================ */

.paper-section {
  margin-bottom: var(--space-12);
}

.paper-section h2 {
  padding-left: var(--space-4);
  border-left: 4px solid var(--color-primary);
  margin-bottom: var(--space-6);
}

.paper-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.paper-list li {
  padding: var(--space-4) 0;
  border-bottom: 1px solid var(--color-border);
}

.paper-list li:last-child {
  border-bottom: none;
}

.paper-title {
  display: block;
  font-weight: var(--font-weight-normal);
  margin-bottom: var(--space-1);
}

.paper-meta {
  display: block;
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

.paper-award {
  color: var(--color-primary);
  font-style: italic;
  margin-left: var(--space-2);
}


/* ============================================================
   9. GPS Journey Navigation
   Sequential prev/next nav at the bottom of journey pages.
   ============================================================ */

.journey-nav {
  margin-top: var(--space-12);
  padding-top: var(--space-6);
  border-top: 2px solid var(--color-border);
}

.journey-label {
  display: block;
  font-size: var(--font-size-sm);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  margin-bottom: var(--space-3);
}

.journey-links {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.journey-prev,
.journey-next {
  font-size: var(--font-size-sm);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: var(--font-weight-normal);
}

/* When only one link exists (first or last page), push it to the right end */
.journey-next:only-child {
  margin-left: auto;
}

.back-to-gps {
  margin-top: var(--space-4);
  font-size: var(--font-size-sm);
}

/* GPS hub journey list — three columns at tablet+ */
.journey-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-8);
  margin-top: var(--space-6);
}

@media (min-width: 768px) {
  .journey-list {
    grid-template-columns: repeat(3, 1fr);
  }
}

.journey-entry {
  border-top: 3px solid var(--color-primary);
  padding-top: var(--space-4);
}

.journey-entry h3 {
  margin-bottom: var(--space-2);
}

.journey-entry p {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-4);
}

.journey-entry .journey-start {
  font-size: var(--font-size-sm);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: var(--font-weight-normal);
}


/* ============================================================
   9. Cards (homepage and GPS hub tile grid)

   Two-section design per card:
     .card-img-box  — white background, colored border (upper)
     .card-body     — solid tile color (lower)
   ============================================================ */

.card-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-6);
  margin: var(--space-8) 0;
}

@media (min-width: 768px) {
  .card-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Optional 3-column grid at desktop width */
@media (min-width: 1100px) {
  .card-grid-3 {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Card base */
.card {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  transition: opacity 0.15s, transform 0.15s;
}

.card:hover {
  opacity: 0.92;
  transform: translateY(-2px);
  text-decoration: none;
}

/* Image box — white background, border color set per variant.
   2px padding = thin white gap between image and colored frame. */
.card-img-box {
  background: var(--color-white);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 2px;
}

.card-img-box img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  display: block;
}

/* Book covers — full cover visible, no cropping */
.card-cover .card-img-box img {
  object-fit: contain;
  height: 240px;
}

/* Portrait photo — anchors crop to top so the face is always visible */
.card-top .card-img-box img {
  object-position: top;
}

/* Landscape card — sizes the image box to 16:9 to match course graphics
   exactly, so cover fills the box with zero clipping and zero whitespace */
.card-landscape .card-img-box {
  aspect-ratio: 16 / 9;
  height: auto;
}

.card-landscape .card-img-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Card body */
.card-body {
  padding: var(--space-4) var(--space-6);
  flex: 1;
}

.card-body h2 {
  font-size: var(--font-size-lg);
  margin-bottom: var(--space-2);
  color: inherit;
}

.card-body p {
  font-size: var(--font-size-sm);
  margin-bottom: 0;
}

/* -- Color variants --
   Each sets: card text color, img-box border, body background, body p color */

.card-red { color: var(--color-white); }
.card-red .card-img-box { border: 3px solid var(--color-primary);   }
.card-red .card-body    { background: var(--color-primary);          }
.card-red .card-body p  { color: rgba(255, 255, 255, 0.85);          }

.card-blue { color: var(--color-white); }
.card-blue .card-img-box { border: 3px solid var(--color-secondary); }
.card-blue .card-body    { background: var(--color-secondary);        }
.card-blue .card-body p  { color: rgba(255, 255, 255, 0.85);          }

.card-purple { color: var(--color-text); }
.card-purple .card-img-box { border: 3px solid #F5E800;              }
.card-purple .card-body    { background: #F5E800;                     }
.card-purple .card-body p  { color: rgba(0, 0, 0, 0.65);             }
.card-purple:hover         { color: var(--color-text);                }

.card-dark { color: var(--color-text); }
.card-dark .card-img-box { border: 2px solid #444444;                }
.card-dark .card-body    { background: #F0F0F0; border: 2px solid #444444; border-top: none; }
.card-dark .card-body p  { color: var(--color-text-muted);           }
.card-dark:hover         { color: var(--color-text);                  }

/* In horizontal feature layout the body sits to the right, not below —
   restore top border and drop left border to avoid doubling with img-box */
.card-dark.card-feature .card-body { border-top: 2px solid #444444; border-left: none; }

/* Wide card — vertical layout, spans full grid width */
.card-wide {
  grid-column: 1 / -1;
}

/* Feature card — horizontal layout, spans full grid width */
.card-feature {
  grid-column: 1 / -1;
  flex-direction: row;
  align-items: stretch;
}

.card-feature .card-img-box {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 200px;
}

.card-feature .card-img-box img {
  width: auto;
  height: 70px;
  padding: 0;
}

@media (max-width: 599px) {
  .card-feature {
    flex-direction: column;
    align-items: stretch;
  }

  .card-feature .card-img-box {
    width: 100%;
    padding: var(--space-4) 0 var(--space-2);
  }
}
