/* ============================================================
   Fab Academy 2026 — Tomi Nieminen
   style.css  |  Simplified & layout-stable rewrite
   ============================================================

   LAYOUT OVERVIEW
   ───────────────
   <body>
     <nav class="topnav">       ← fixed top bar, full width
     <div class="page-wrapper"> ← flex row, fills viewport below nav
       <nav class="sidebar">    ← optional left sidebar (assignment pages)
       <main class="content">   ← all page content goes here
     </div>

   HORIZONTAL POSITIONING
   ──────────────────────
   Everything is centred through .content's --content-max + auto margins.
   Never use position:absolute or float for layout — use flex/grid.
   To add a new block, just drop it inside <main class="content">.

   IMAGES & VIDEOS
   ───────────────
   Images and videos are centred relative to the text column.
   Use <img>, <video>, or <iframe> directly — no wrapper needed.
   They centre automatically via margin: 1rem auto.

   SIDEBAR COLLAPSE
   ────────────────
   When .sidebar gains the .collapsed class (via sidebar-toggle.js),
   the content column's max-width grows by 20% automatically.
   ============================================================ */

/* ── Reset & base ─────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ── Design tokens ────────────────────────────────────────── */
:root {
  /* Colors — matched to original style.css */
  --color-bg:          #ffffff;
  --color-surface:     #ffffff;
  --color-border:      lightgray;
  --color-text:        #024750;
  --color-text-muted:  teal;
  --color-accent:      #024750;
  --color-accent-hover:#009090;
  --color-accent-soft: #e6f4f4;
  --color-nav-bg:      #024750;
  --color-nav-text:    #ffffff;
  --color-sidebar-bg:  #ffffff;

  /* Typography — original uses Optima */
  --font-body:  'Optima', 'Candara', 'Segoe UI', sans-serif;
  --font-ui:    'Optima', 'Candara', 'Segoe UI', sans-serif;
  --font-code:  'Courier New', monospace;

  /* Spacing scale */
  --sp-xs:  0.375rem;   /*  6px */
  --sp-sm:  0.75rem;    /* 12px */
  --sp-md:  1.25rem;    /* 20px */
  --sp-lg:  2rem;       /* 32px */
  --sp-xl:  3rem;       /* 48px */

  /* Layout */
  --topnav-height: 4rem;
  --content-max:   780px;
  --content-pad:   clamp(1rem, 4vw, 2.5rem);

  /* Misc */
  --radius:    4px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.10);
  --shadow-md: 0 3px 10px rgba(0,0,0,.13);
  --transition: 180ms ease;
}

/* ── Base elements ────────────────────────────────────────── */
html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  font-family: var(--font-body);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.7;
  padding-top: var(--topnav-height);
  min-height: 100vh;
}

/* ── Top navigation ───────────────────────────────────────── */
.topnav {
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--topnav-height);
  background: var(--color-nav-bg);
  display: flex;
  align-items: center;
  gap: var(--sp-lg);
  padding: 0 var(--content-pad);
  z-index: 100;
  box-shadow: var(--shadow-md);
}

.topnav a {
  font-family: var(--font-ui);
  font-size: 1rem;
  font-weight: 500;
  color: var(--color-nav-text);
  text-decoration: none;
  letter-spacing: 0.1em;
  white-space: nowrap;
  padding: var(--sp-xs) 0.5rem;
  border-bottom: 2px solid transparent;
  transition: color var(--transition), background var(--transition);
}

.topnav a:first-child {
  font-weight: 500;
  font-size: 1.2rem;
  letter-spacing: 0.1em;
  margin-right: auto;
  color: #ffffff;
  border-bottom: none;
}

.topnav a:hover,
.topnav a.active {
  color: #ffffff;
  background-color: var(--color-accent-hover);
  border-radius: 10%;
}

.nav-toggle {
  display: none;
}

.vain {
  display: block;
  position: fixed;
  height: 2px;
  width: 100%;
  background-color: var(--color-nav-bg);;
  margin-top: 0.11rem;
  z-index: 1000;
}

/* ── Page wrapper (sidebar + content side-by-side) ─────────── */
.page-wrapper {
  display: flex;
  align-items: flex-start;
  min-height: calc(100vh - var(--topnav-height));
}

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
  width: 18.5%;
  flex-shrink: 0;
  background: var(--color-sidebar-bg);
  position: sticky;
  top: var(--topnav-height);
  height: calc(100vh - var(--topnav-height));
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--sp-md) var(--sp-sm);
  transition: width 280ms ease, padding 280ms ease;
  scrollbar-width: thin;
  scrollbar-color: rgba(2, 71, 80, 0.35) transparent;
  border-right: solid rgba(0, 128, 128, 0.5) 1px;
}

.sidebar::-webkit-scrollbar        { width: 4px; }
.sidebar::-webkit-scrollbar-track  { background: transparent; }
.sidebar::-webkit-scrollbar-thumb  { background: rgba(2,71,80,.35); border-radius: 2px; }
.sidebar::-webkit-scrollbar-thumb:hover { background: var(--color-accent); }

.table-of-contents {
    margin-left: 10%;
}

/* Collapsed state */
.sidebar.collapsed {
  width: 28px;
  padding: var(--sp-md) 0;
  overflow-y: hidden;
  border-left: solid 2px #024750;
}

.sidebar.collapsed .sidebar-links {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transition: opacity 180ms ease, visibility 180ms ease;
}

.sidebar-links {
  opacity: 1;
  visibility: visible;
  transition: opacity 180ms ease 80ms, visibility 180ms ease 80ms;
}

/* Toggle button — injected by sidebar-toggle.js into <body> */
.sidebar-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 44px;
  cursor: pointer;
  color: var(--color-accent);
  background: none;
  border: none;
  border-radius: var(--radius);
  padding: 0;
  flex-shrink: 0;
  transition: background var(--transition), color var(--transition);
  position: fixed;
  top: 50vh;
  transform: translateY(-50%);
  z-index: 10;
  margin-left: 10px;
}

.sidebar-toggle:hover {
  background: var(--color-accent-soft);
  color: var(--color-accent-hover);
}

.sidebar-toggle svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

/* Sidebar nav links */
.sidebar a {
  display: block;
  font-family: var(--font-ui);
  font-size: 0.78rem;
  line-height: 1.4;
  color: teal;
  text-decoration: none;
  padding: var(--sp-xs) var(--sp-sm);
  border-radius: var(--radius);
  margin-bottom: 2px;
  white-space: normal;
  transition: background var(--transition), color var(--transition);
}

.sidebar a:hover,
.sidebar a.active {
  background: var(--color-accent-soft);
  color: var(--color-accent);
}

.sidebar a strong {
  display: block;
  font-size: 0.82rem;
  color: var(--color-text);
  margin-bottom: var(--sp-xs);
  padding-left: var(--sp-sm);
}

/* ── Main content area ────────────────────────────────────── */
.content {
  flex: 1 1 0;
  min-width: 0;
  padding: var(--sp-xl) var(--content-pad);
}

/*
  Every direct child of .content is constrained to --content-max
  and centred with auto margins. This is the single source of truth
  for horizontal positioning — never use position:absolute or float.
*/
.content > * {
  max-width: var(--content-max);
  margin-left: auto;
  margin-right: auto;
}

/*
  When the sidebar is collapsed, grow the content column by 20%.
  780 × 1.2 = 936px. The :has() selector has full browser support
  as of 2024. On older browsers it falls back to 780px gracefully.
*/
.page-wrapper:has(.sidebar.collapsed) .content > * {
  max-width: calc(var(--content-max) * 1.2);
}

/* ── Typography ───────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-ui);
  line-height: 1.25;
  color: var(--color-text);
  margin-top: var(--sp-xl);
  margin-bottom: var(--sp-sm);
}

h1 { font-size: clamp(1.6rem, 4vw, 2.2rem); font-weight: 700; text-decoration: none; text-align: center;   margin-top:0;}
h2 { font-size: 1.45rem; font-weight: 700; }
h3 { font-size: 1.15rem; font-weight: 600; }
h4 { font-size: 1rem;    font-weight: 600; }

p { margin-bottom: var(--sp-md); }

a {
  color: var(--color-accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  font-weight: 700%;
}
a:hover { text-decoration: none; }

.content a {
  font-weight: 700;
}

ul, ol {
  padding-left: 1.4em;
  margin-bottom: var(--sp-md);
}
li { margin-bottom: var(--sp-xs); }

code {
  font-family: var(--font-code);
  font-size: 0.88em;
  background: lightgray;
  padding: 0.2rem 0.35rem;
  border-radius: var(--radius);
}

pre {
  background: lightgray;
  color: var(--color-text);
  padding: var(--sp-md);
  border-radius: var(--radius);
  overflow-x: auto;
  margin-bottom: var(--sp-md);
  font-size: 0.85rem;
  line-height: 1.5;
}
pre code { background: none; padding: 0; color: inherit; font-size: inherit; }

blockquote {
  border-left: 3px solid var(--color-accent);
  padding: var(--sp-sm) var(--sp-md);
  margin: var(--sp-md) 0;
  color: var(--color-accent);
  font-style: italic;
  background: var(--color-accent-soft);
  border-radius: 0 var(--radius) var(--radius) 0;
}

hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: var(--sp-xl) 0;
}

/* ── Images & media ───────────────────────────────────────── */
/*
  Images, videos and iframes are indented 10% from the left text border.
  margin: 1rem 0 1rem 10% — top 1rem, right 0, bottom 1rem, left 10%.
  max-width: 90% ensures they never overflow the right edge.
  display: block is required — inline elements ignore left/right margins.
*/
img {
  display: block;
  max-width: 60%;
  height: auto;
  border-radius: var(--radius);
  margin: 1rem 0 1rem 10%;
}

.assignment-img {
  width: 600px;
  margin-bottom: 2rem;
}

video {
  display: block;
  max-width: 90%;
  height: auto;
  border-radius: var(--radius);
  margin: 1rem 0 1rem 10%;
}

iframe {
  display: block;
  max-width: 90%;
  margin: 1rem 0 1rem 10%;
  border: none;
  border-radius: var(--radius);
}

.index-page {
  margin: auto;
}

.index-page h1 {
  text-align: center;
  margin: 1.2rem;
  font-size: 1.5rem;
}

.index-page h2 {
  text-align: center;
  margin: 1.2rem;
  font-size: 1.3rem;
}

.index-page .hero-image {
  margin: 1rem auto;
  max-width: 100%;
}

/*
  .assignment-text, .assignment-img, .assignment-video:
  The original CSS used position:relative + left:15% on these containers
  which caused the 10% img margin-left to be relative to an already-shifted
  box. We neutralise the offset here so the 10% is always relative to the
  true text column left edge.
*/
.assignment-text,
.assignment-img,
.assignment-video {
  display: block;
  position: static;
  left: 0;
  width: 100%;
  max-width: 100%;
  margin-bottom: 2rem;
}

/* Hero image — full width, no indent */
.hero-image {
  width: 100%;
  max-width: var(--content-max);
  aspect-ratio: 16 / 7;
  object-fit: cover;
  margin: 0 auto var(--sp-lg) auto;
}

.image-container {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: var(--sp-md);
  margin: 1rem 0 2rem 3rem;
  max-width: 90%;
  align-items:center;
  justify-content: center;
}

.image-container img {
  max-width: 100%;
  height: auto;
  flex-shrink: 1;   /* shrink gracefully on narrow screens */
  margin: 0;        /* override the global img margin */
}

.image-container video {
  max-width: 100%;
  height: auto;
  flex-shrink: 1;   /* shrink gracefully on narrow screens */
  margin: 0;        /* override the global img margin */
}

/* ── Assignment card grid (assignments overview page) ─────── */
/*
  Usage:
    <div class="card-grid">
      <a class="card" href="...">
        <img src="..." alt="...">
        <span>Week 1. Title</span>
      </a>
    </div>
*/
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--sp-md);
  margin-top: var(--sp-lg);
  margin-bottom: var(--sp-xl);
  /* inherits max-width + auto margins from .content > * */
}

.card {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition), box-shadow var(--transition);
}

.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.card img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 0;
  margin: 0;        /* no indent inside cards */
  max-width: 100%;
}

.card span {
  font-family: var(--font-ui);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--color-text);
  padding: var(--sp-sm);
  line-height: 1.4;
}

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

/* ── Tables ───────────────────────────────────────────────── */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  margin-bottom: var(--sp-md);
}

th {
  background: var(--color-nav-bg);
  color: var(--color-nav-text);
  font-family: var(--font-ui);
  font-weight: 600;
  text-align: left;
  padding: var(--sp-sm) var(--sp-md);
}

td {
  padding: var(--sp-sm) var(--sp-md);
  border-bottom: 1px solid var(--color-border);
}

.bom-table {
  font-weight: 500;
}

.bom-table tr td:first-child{
  font-weight: 700;
}
.bom-table tr td:nth-child(3){
  text-align: center;
}
.bom-table tr td:nth-child(4){
  text-align: center;
}

tr:last-child td { border-bottom: none; border-top: solid rgba(2, 71, 80, 0.5) 2px; font-weight: 700;}
tr:nth-child(even) td { background: var(--color-accent-soft); }

tr:nth-child(even) td { background: var(--color-accent-soft); }

/* ── Previous final project ideas section ───────────────────────────── */
.fp-ideation__content {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 380ms ease;
}

.fp-ideation__content > * {
  overflow: hidden;
}

.fp-ideation.open .fp-ideation__content {
  grid-template-rows: 1fr;
  background-color: #0090900f;
  padding: 1rem;
}

.fp-ideation__btn {
  font-family: var(--font-ui);
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-accent-hover);
  background: none;
  border: none;
  cursor: pointer;
  padding: var(--sp-xs) 0;
  margin: var(--sp-md) 0;
  text-decoration: underline;
}

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

[id] {
  scroll-margin-top: 6rem;
}


/* ── Mobile-first responsive ──────────────────────────────── */
/*
  All rules below apply only at ≤700px.
  Nothing above this breakpoint is changed.
*/
@media (max-width: 700px) {

  /* ── Root token overrides ─────────────────────────────────── */
  :root {
    --sp-xl: 2rem;
    --sp-lg: 1.5rem;
    --content-pad: 1rem;
  }

  body {
    padding-top: 0; /* nav-mobile.js sets this dynamically */
  }

  /* ── Top nav — title on row 1, hamburger centred on row 2 ── */
  .topnav {
    position: fixed;
    top: 0; left: 0; right: 0;
    flex-direction: column;
    align-items: center;       /* centre everything */
    gap: 0;
    padding: 0.4rem var(--sp-md);
    height: auto;
    z-index: 100;
  }

  /* Site title — full width, centred, wraps freely */
  .topnav a:first-child {
    width: 100%;
    text-align: center;
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
    font-size: clamp(0.82rem, 3.8vw, 1rem);
    line-height: 1.3;
    padding: 0.35rem 0 0.1rem 0;
    border-bottom: none;
    margin-right: 0;           /* cancel desktop margin-right:auto */
  }

  /* Hamburger button — centred below the title, 2 bars */
  .nav-toggle {
    display: flex !important;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    width: 36px;
    height: 26px;
    cursor: pointer;
    background: none;
    border: none;
    padding: 4px;
    margin: 0.15rem 0 0.3rem 0;
    color: white;
    border-radius: var(--radius);
    flex-shrink: 0;
    align-self: center;
  }

  .nav-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background: white;
    border-radius: 2px;
    transition: transform 250ms ease, opacity 250ms ease;
  }

  /* 2-bar hamburger: only 2 spans used — hide the third */

  /* Animate 3 bars → X when open */
  .topnav.nav-open .nav-toggle span:nth-child(1) {
    transform: translateY(3.5px) rotate(45deg);
  }
  .topnav.nav-open .nav-toggle span:nth-child(2) {
    transform: translateY(-3.5px) rotate(-45deg);
  }
  .topnav.nav-open .nav-toggle span:nth-child(3) {
    display: none;
  }

  /* Nav links — hidden by default, centred when open */
  .topnav a:not(:first-child):not(.nav-toggle) {
    display: none;
    width: 100%;
    text-align: center;
    padding: 0.6rem var(--sp-md);
    font-size: 0.95rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    border-radius: 0;
    white-space: normal;
  }

  .topnav.nav-open a:not(:first-child):not(.nav-toggle) {
    display: block;
  }

  /* ── Hide sidebar + toggle on mobile ─────────────────────── */
  .sidebar,
  .sidebar-toggle {
    display: none !important;
  }

  /* ── Content area ─────────────────────────────────────────── */
  .content {
    padding: var(--sp-lg) var(--content-pad);
  }

  .content > * {
    max-width: 100%;
  }

  /* ── Typography ───────────────────────────────────────────── */
  h1 { font-size: clamp(1.1rem, 5vw, 1.6rem); }
  h2 { font-size: clamp(0.9rem, 4vw, 1.3rem); }
  h3 { font-size: clamp(0.85rem, 3.5vw, 1.1rem); }

  /* ── Images & video — full width, centred, no left indent ── */
  img {
    max-width: 100%;
    width: 100%;
    margin: 1rem auto;
  }

  video {
    max-width: 100%;
    width: 100%;
    margin: 1rem auto;
  }

  iframe {
    max-width: 100%;
    width: 100%;
    margin: 1rem auto;
  }

  .image-container {
    flex-direction: column;
    margin: 1rem auto;
    max-width: 100%;
    align-items: center;
  }

  .image-container img,
  .image-container video {
    width: 100%;
    max-width: 100%;
  }

  .hero-image {
    aspect-ratio: 16 / 9;
    margin: 0 auto var(--sp-md) auto;
  }

  /* ── Tables ───────────────────────────────────────────────── */
  table {
    font-size: 0.8rem;
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  th, td {
    padding: var(--sp-xs) var(--sp-sm);
  }

  /* ── Card grid ────────────────────────────────────────────── */
  .card-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: var(--sp-sm);
  }

  /* ── Week cards ───────────────────────────────────────────── */
  /*
    COLLAPSED: entire card is a tap target that expands it.
               thumb (68px square) | h1 title
               btn-row hidden — tap anywhere on card to expand

    EXPANDED:  thumb shrinks to 38px | h1 stays visible
               h2 subheadings appear below thumb+info row
               detail panel full width below
               btn-row visible to collapse

    h2 is hidden when collapsed, shown only when expanded.
    All inline width/height on video/img overridden to 100%.
  */

  .week-card {
    grid-template-columns: 38px 1fr !important;
    grid-template-rows: 38px 0fr auto !important;
    grid-template-areas:
      "thumb  info"
      "detail detail"
      "btn    btn";
    cursor: pointer;            /* whole card is tappable when collapsed */
  }

  .week-card.open {
    grid-template-columns: 38px 1fr;
    grid-template-rows: 38px 1fr auto;
    grid-template-areas:
      "thumb  info"
      "detail detail"
      "btn    btn";
    cursor: default;
  }

  /* Thumb */
  .week-card__thumb {
    width: 38px !important;
    height: 38px !important;
  }

  .week-card.open .week-card__thumb {
    width: 38px !important;
    height: 38px !important;
  }

  .week-card__thumb img {
    width: 38px !important;
    height: 38px !important;
    margin: 0;
  }

  .week-card.open .week-card__thumb img {
    width: 38px;
    height: 38px;
  }

  /* Info panel — contains only h1 on mobile */
  .week-card__info {
    min-height: 38px !important;
    padding: var(--sp-xs) var(--sp-sm);
    /* reset desktop padding-left offset */
    padding-left: var(--sp-sm) !important;
  }

  .week-card.open .week-card__info {
    min-height: 38px;
    padding: var(--sp-xs) var(--sp-sm) !important;
  }

  /* h1 — fluid size, wraps freely, reset desktop muted colour */
  .week-card__info h1 {
    font-size: clamp(0.78rem, 3.5vw, 1rem) !important;
    font-weight: 600 !important;
    color: var(--color-accent) !important;
    line-height: 1.25;
    white-space: normal;
    overflow: visible;
    margin-top: 0;
    margin-bottom: 0 !important;
    text-align: left;
    padding-left: 5px !important;
  }

  .week-card__info h1 a {
    color: var(--color-accent) !important;
    font-size: clamp(0.78rem, 3.5vw, 1rem) !important;
    font-weight: 600 !important;
  }

  /* h2 subheading — hidden when collapsed, shown in own row when open.
     Uses grid-area "sub" which only exists in .week-card.open.         */
  .week-card__info h2 {
    /* hide completely when collapsed */
    display: none !important;
    /* reset all desktop offsets */
    padding-left: 0 !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  /* When open: h2 floats absolutely over the top of the detail area.
     It sits just below the info row (38px from top of card).
     detail-inner gets margin-top to clear the h2 height.            */
  .week-card.open .week-card__info h2 {
    display: block !important;
    position: absolute;
    top: 38px;                /* pinned just below the info row */
    left: 0;
    right: 0;
    z-index: 3;
    /* reset all desktop offsets */
    margin-left: 0 !important;
    margin-right: 0 !important;
    width: 100%;
    font-size: clamp(0.72rem, 3vw, 0.85rem) !important;
    font-weight: 400 !important;
    color: var(--color-text-muted) !important;
    line-height: 1.4;
    white-space: normal;
    padding: var(--sp-xs) var(--sp-sm);
    border-top: 1px solid var(--color-border);
    background: var(--color-surface);  /* so it visually sits on top of detail */
    max-height: none;
    opacity: 1;
    overflow: visible;
  }

  /* Btn-row — visible in both collapsed and expanded states on mobile */

  /* Detail panel — reset desktop margin-top, full width, no left offset */
  .week-card__detail {
    margin-top: 0 !important;
  }

  .week-card.open .week-card__detail {
    padding-left: 0;
    cursor: pointer;   /* tapping detail collapses card (videos excluded in JS) */
  }

  /* Push detail content below the absolutely positioned h2.
     2rem ≈ h2 line-height + padding — adjust if h2 wraps to two lines. */
  .week-card.open .week-card__detail-inner {
    margin-top: 2rem !important;
  }

  /* Videos must not propagate the collapse tap */
  .week-card__detail video {
    cursor: auto;
    position: relative;
    z-index: 2;
  }

  .week-card__detail-inner {
    padding: 0;
  }

  .week-card.open .week-card__detail-inner {
    padding: var(--sp-sm);
  }

  /* All media inside detail: override inline width styles */
  .week-card__detail img,
  .week-card__detail video,
  .week-card__detail iframe {
    max-width: 100% !important;
    width: 100% !important;
    margin: var(--sp-sm) 0;
  }

  .week-card__detail .image-container {
    flex-direction: column;
    margin: var(--sp-sm) 0;
  }

  .week-card__detail .image-container img,
  .week-card__detail .image-container video {
    width: 100% !important;
    max-width: 100% !important;
    flex: none;
    margin: var(--sp-xs) 0;
  }

} /* end @media (max-width: 700px) */

/* ── Index page ───────────────────────────────────────────── */
.index-page {
  margin-top: 1rem;
}

.index-page h1 {
  font-size: 1.2rem;
}

.index-page h2 {
  font-size: 1rem;
}

/* Wrapper for all week cards */
.weeks-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-sm);
  margin-top: var(--sp-lg);
}

/* Grid layout:
   col 1: 150px → 75px  — reserved for thumb (thumb is position:absolute)
   col 2: 1fr           — info / detail / btn

   row 1: 150px → 75px  — info row (sets card top height)
   row 2: 0fr   → 1fr   — detail panel
   row 3: auto          — btn-row (always visible, behind thumb when collapsed) */

.week-card {
  display: grid;
  grid-template-columns: 120px 1fr;
  grid-template-rows: 120px 0fr auto;
  grid-template-areas:
    "thumb  info"
    "detail detail"
    "btn    btn";
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--color-surface);
  position: relative;
  transition: grid-template-rows 380ms ease, grid-template-columns 380ms ease;
  box-shadow: var(--shadow-md);
}
.week-card:hover {
  box-shadow: var(--shadow-md);
}
.week-card.open {
  grid-template-columns: 75px 1fr;
  grid-template-rows: 75px 1fr auto;
}

/* Thumbnail — absolutely positioned, covers btn-row when collapsed */
.week-card__thumb {
  grid-area: thumb;
  position: absolute;
  top: 0;
  left: 0;
  width: 120px;
  height: 120px;
  overflow: hidden;
  text-decoration: none;
  z-index: 2;   /* above btn-row gradient */
  transition: width 380ms ease, height 380ms ease;
}

.week-card.open .week-card__thumb {
  width: 75px;
  height: 75px;
}

.week-card__thumb img {
  width: 120px;
  height: 120px;
  object-fit: cover;
  border-radius: 0;
  margin: 0;
  max-width: 100%;
  display: block;
  transition: transform 300ms ease, width 380ms ease, height 380ms ease;
}

.week-card.open .week-card__thumb img {
  width: 60px;
  height: 60px;
}

.week-card__thumb:hover img {
  transform: scale(1.04);
}

/* Info panel — padding removed; h1/h2 control their own left offset */
.week-card__info {
  grid-area: info;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  padding: var(--sp-sm) var(--sp-md) var(--sp-sm) 0;
  overflow: hidden;
  transition: padding 380ms ease;
}

/* h1 — 50px from the thumb right edge (grid col 2 starts at thumb edge) */
.week-card__info h1 {
  margin-top: 0;
  margin-bottom: 0.1rem;
  margin-left: 0px;
  padding-left: 50px;
  text-decoration: none;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--color-accent);
  line-height: 1.3;
}

.week-card__info h1 a {
  color: var(--color-accent);
  text-decoration: none;
  font-weight: 700;
  font-size: 1.3rem;
}

.week-card__info h1 a:hover {
  text-decoration: underline;
}

/* h2 — 50px from left, 0.5rem gap below h1 */
.week-card__info h2 {
  font-size: 0.85rem;
  font-weight: 700;
  margin: 0.5rem 0 0.2rem 0;
  padding-left: 75px;
  line-height: 1.25;
  transition: font-size 380ms ease, margin 380ms ease;
  text-align: left;
  max-height: none;
  overflow: visible;
  opacity: 1;
  display: block;
  color: var(--color-text-muted);
}

.week-card__info h2 a {
  color: var(--color-accent);
  text-decoration: none;
  font-weight: 700;
}

.week-card__info h2 a:hover {
  text-decoration: underline;
}

/* When open: h1 grows to title size, h2 shrinks to subheading below it */
.week-card.open .week-card__info h1 {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 0.1rem;
  margin-left: 0;
  padding-left: 50px;
}

.week-card.open .week-card__info h1 a {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--color-accent);
}

.week-card.open .week-card__info h2 {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--color-text-muted);
  margin: 0.5rem 0 0 0;
  padding-left: 75px;
  text-align: center;
}

.week-card__info h3 {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--color-text-muted);
  margin: 0;
  line-height: 1.4;
  overflow: hidden;
  max-height: 4rem;
  transition: max-height 380ms ease, opacity 200ms ease, margin 380ms ease;
  padding: 1rem;
}

.week-card.open .week-card__info h3 {
  max-height: 0;
  opacity: 0;
  margin: 0;
}

/* Clicking anywhere on an open card (except links/videos) collapses it */
.week-card.open {
  cursor: pointer;
}

/* Detail area — cursor hint that it's clickable to collapse */
.week-card.open .week-card__detail {
  cursor: pointer;
}

/* Detail panel */
.week-card__detail {
  grid-area: detail;
  display: grid;
  grid-template-rows: 0fr;
  background: transparent;
  transition: grid-template-rows 380ms ease;
  margin-top: 1rem;   /* push detail content below the thumb/info row */
}

.week-card.open .week-card__detail {
  grid-template-rows: 1fr;
}

.week-card__detail-inner {
  overflow: hidden;
  padding: 0 var(--sp-md);
  transition: padding 380ms ease;
}

.week-card.open .week-card__detail-inner {
  padding: var(--sp-md);
}

.week-card__detail-inner p {
  font-size: 0.9rem;
  line-height: 1.6;
  margin-bottom: var(--sp-sm);
  color: var(--color-text);
}

.week-card__detail img,
.week-card__detail video,
.week-card__detail iframe {
  height: auto;
  border-radius: var(--radius);
}

.week-card__detail .image-container {
  display: flex;
  flex-direction: row;
  gap: var(--sp-md);
  flex-wrap: wrap;
  margin: var(--sp-sm) 0;
  justify-content: center;
  align-items: center; 
}

.week-card__detail .image-container img {
  margin: 1rem 0;
}

/* Button row — always last.
   z-index: 1 so it renders above the card bg but the thumb (z-index:2)
   covers it when collapsed.                                             */
.week-card__btn-row {
  grid-area: btn;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 22px;
  position: relative;
  overflow: hidden;
  z-index: 1;
}

.week-card__btn-row::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    #ffffff 0%,
    rgba(2, 71, 80, 0.15) 100%
  );
  opacity: 0;
  transition: opacity 280ms ease;
  pointer-events: none;
}

/* Show gradient on hover only when collapsed */
.week-card:not(.open):hover .week-card__btn-row::before {
  opacity: 1;
}

.week-card__expand-btn {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  cursor: pointer;
  color: var(--color-accent);
  background: none;
  border: none;
  border-radius: var(--radius);
  padding: 0;
  transition: color 180ms ease;
  flex-shrink: 0;
}

.week-card__expand-btn svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}