/* ====================================================================== */
/* WORD BABEL — V2 STYLESHEET                                              */
/* Slimmed-down core: ribbon, page shell, three-tile home, data-vis pages. */
/* ====================================================================== */

/* ---------------------------------------------------------------------- */
/* FONTS                                                                  */
/* ---------------------------------------------------------------------- */

/* Winky Rough */
@font-face {
  font-family: 'Winky Rough';
  src: url('/static/fonts/Winky_Rough/WinkyRough-VariableFont_wght.ttf') format('truetype');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* Felix Titling */
@font-face {
  font-family: 'Felix Titling';
  src: url('/static/fonts/FELIXTI.TTF') format('truetype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

/* Cinzel */
@font-face {
  font-family: 'Cinzel';
  src: url('/static/fonts/Cinzel/static/Cinzel-Regular.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

/* ---------------------------------------------------------------------- */
/* BASE / SHELL                                                           */
/* ---------------------------------------------------------------------- */

body {
  margin: 0;
  min-height: 100vh;
  /*
   * Papyrus outer margin — layered to mimic aged paper:
   * base warm sand + directional grain noise + tonal depth blobs
   */
  background-color: #a97e52;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='500' height='500'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.72 0.18' numOctaves='4' seed='5' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0.3'/%3E%3C/filter%3E%3Crect width='500' height='500' filter='url(%23n)' opacity='0.30'/%3E%3C/svg%3E"),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='f'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.15 0.85' numOctaves='2' seed='12' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0.15'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23f)' opacity='0.14'/%3E%3C/svg%3E"),
    radial-gradient(ellipse at 18% 12%, rgba(215,185,135,0.60) 0%, transparent 52%),
    radial-gradient(ellipse at 82% 85%, rgba(120,85,40,0.50) 0%, transparent 48%),
    radial-gradient(ellipse at 55% 50%, rgba(165,130,80,0.30) 0%, transparent 38%);
  font-family: Arial, sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.content-shell {
  position: relative;
  min-height: 100%;
  display: flex;
  justify-content: center;
  width: 100%;
}

.content_wrapper {
  width: 85%;
  max-width: 100%;
  margin: 0 auto;
  padding: 10px;
  min-height: 100vh;
  /*
   * The page surface — warm cream with a very fine grain so it reads
   * as old paper rather than flat paint.
   */
  background-color: #ede0c0;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='400' height='400'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.88 0.72' numOctaves='4' seed='8' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0.2'/%3E%3C/filter%3E%3Crect width='400' height='400' filter='url(%23g)' opacity='0.12'/%3E%3C/svg%3E"),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='600' height='600'%3E%3Cfilter id='h'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.10 0.90' numOctaves='3' seed='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0.1'/%3E%3C/filter%3E%3Crect width='600' height='600' filter='url(%23h)' opacity='0.07'/%3E%3C/svg%3E");
  border-radius: 0 0 10px 10px;
  box-shadow: 0 8px 40px rgba(100, 75, 35, 0.28);
  position: relative;
  z-index: 2;
}

@media (max-width: 768px) {
  .content_wrapper { padding: 10px; }
}

/* ---------------------------------------------------------------------- */
/* NAVIGATION RIBBON                                                      */
/* ---------------------------------------------------------------------- */

/* ── Compact ribbon navbar (sub-pages + collapsed home) ── */
.navbar {
  background: #ede0c0;
  border-bottom: 1px solid rgba(180,155,100,0.3);
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  position: sticky;
  top: 0;
  z-index: 1000;
}

.nav-inner {
  display: flex;
  align-items: center;
  width: 100%;
  max-width: 1300px;
  padding: 0 32px;
  box-sizing: border-box;
  gap: 0;
}

.nav-wordmark {
  font-family: 'Felix Titling', serif;
  font-size: 19px;
  letter-spacing: 2px;
  color: #6E1D1D;
  text-decoration: none;
  white-space: nowrap;
  margin-right: auto;
  transition: opacity 0.2s ease;
}

.nav-wordmark:hover { opacity: 0.7; }

.nav-links {
  display: flex;
  gap: 28px;
  align-items: center;
}

.nav-cat-link {
  font-family: 'Felix Titling', serif;
  font-size: 11px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: #6E1D1D;
  text-decoration: none;
  opacity: 0.55;
  transition: opacity 0.2s ease;
  position: relative;
  padding-bottom: 2px;
}

.nav-cat-link:hover { opacity: 1; }

.nav-cat-link::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0; right: 0;
  height: 1px;
  background: #6E1D1D;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.2s ease;
}

.nav-cat-link:hover::after,
.nav-cat-link.active::after { transform: scaleX(1); }
.nav-cat-link.active         { opacity: 1; }

/* Visual separator between primary and secondary nav links */
.nav-sep {
  display: inline-block;
  width: 1px;
  height: 16px;
  background: rgba(180,155,100,0.55);
  vertical-align: middle;
}

/* Secondary nav links (About / Support) — slightly more muted */
.nav-cat-link--sec { opacity: 0.38; font-size: 10px; letter-spacing: 1.2px; }

/* ---------------------------------------------------------------------- */
/* HOME — HERO (expanded) + RIBBON (collapsed)                           */
/* ---------------------------------------------------------------------- */

.vh-hero {
  width: 100%;
  background: #ede0c0;
  border-bottom: 1px solid rgba(180,155,100,0.25);
  position: sticky;
  top: 0;
  z-index: 1000;
  overflow: hidden;
}

.vh-hero-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  padding: 52px 40px 36px;
  max-width: 1300px;
  margin: 0 auto;
  box-sizing: border-box;
  transition: padding 0.38s ease;
}

/* Expanded: title and subtitle each occupy a full row */
.vh-hero-title {
  width: 100%;
  text-align: center;
  font-family: 'Felix Titling', serif;
  font-size: 54px;
  letter-spacing: 5px;
  color: #6E1D1D;
  margin: 0 0 6px;
  transition: font-size 0.38s ease, letter-spacing 0.38s ease,
              width 0.38s ease, margin 0.38s ease;
}

/* Category nav — vertical stack in expanded hero, row in ribbon */
.vh-cat-nav {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  transition: gap 0.38s ease, width 0.38s ease;
}

.vh-cat-btn {
  background: transparent;
  border: none;
  padding: 6px 0;
  font-family: 'Felix Titling', serif;
  font-size: 34px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: #6E1D1D;
  opacity: 0.70;
  cursor: pointer;
  position: relative;
  transition: opacity 0.2s ease, font-size 0.38s ease, letter-spacing 0.38s ease,
              transform 0.22s ease;
}

.vh-cat-btn:hover  { opacity: 0.90; transform: translateY(-5px); }
.vh-cat-btn.active { opacity: 1; }

/* Row 2 buttons (New Content / Top Content) — slightly smaller than row 1 */
.vh-cat-btn--sm {
  font-size: 22px;
  letter-spacing: 2px;
  opacity: 0.58;
}
.vh-cat-btn--sm:hover  { opacity: 0.82; transform: translateY(-5px); }
.vh-cat-btn--sm.active { opacity: 1; }

.vh-cat-btn::after {
  content: '';
  position: absolute;
  bottom: -3px;
  left: 0; right: 0;
  height: 1.5px;
  background: #6E1D1D;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.2s ease;
}
.vh-cat-btn.active::after { transform: scaleX(1); }

/* ─── Title link (explicit font so <a> never falls back to browser default) ─── */
.vh-hero-title-link {
  font-family: 'Felix Titling', serif;
  color: inherit;
  text-decoration: none;
  transition: opacity 0.2s ease;
}
.vh-hero-title-link:hover { opacity: 0.72; }

/* ─── Nav rows (groups of items laid out horizontally) ─── */
.vh-nav-row {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  justify-content: center;
  width: 100%;
  gap: 0;
  padding: 14px 0 6px;
  border-bottom: 1px solid rgba(213, 206, 115, 0.55);
}

/* ─── Vertical nav item wrappers ─── */
.vh-nav-item {
  flex: 1;
  max-width: 260px;
  text-align: center;
}

/* Flyout panel — hidden until hover */
.vh-flyout {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  transition: max-height 0.32s ease, opacity 0.22s ease, padding 0.28s ease;
}

.vh-nav-item:hover .vh-flyout {
  max-height: 300px;
  opacity: 1;
  padding: 10px 0 16px;
}

.vh-flyout-tiles {
  display: flex;
  gap: 14px;
  justify-content: center;
  flex-wrap: wrap;
}

/* Mini flyout tiles */
.vh-flyout-tile {
  width: 130px;
  height: 95px;
  background: #ede0c4;
  border: 1.5px solid rgba(180,155,100,0.45);
  border-radius: 10px;
  text-decoration: none;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.vh-flyout-tile:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(0,0,0,0.16);
}
.vh-flyout-tile-img {
  position: absolute;
  inset: 0;
  overflow: hidden;
}
.vh-flyout-tile-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.28;
  transition: opacity 0.25s ease;
}
.vh-flyout-tile:hover .vh-flyout-tile-img img { opacity: 0.45; }

.vh-flyout-tile-label {
  position: relative;
  z-index: 1;
  font-family: 'Felix Titling', serif;
  font-size: 10px;
  letter-spacing: 0.4px;
  color: #6E1D1D;
  text-align: center;
  padding: 5px 8px;
  background: rgba(255,255,255,0.82);
  border-radius: 5px;
  line-height: 1.35;
}

/* "→ View all" link inside flyout */
.vh-flyout-viewall {
  font-family: 'Felix Titling', serif;
  font-size: 10px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: #6E1D1D;
  text-decoration: none;
  opacity: 0.55;
  transition: opacity 0.2s ease;
}
.vh-flyout-viewall:hover { opacity: 1; }

/* Secondary nav row: About & Support (single link) */
.vh-nav-secondary {
  display: flex;
  justify-content: center;
  padding: 10px 0 8px;
  width: 100%;
}

.vh-nav-sec-link {
  font-family: 'Felix Titling', serif;
  font-size: 16px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #6E1D1D;
  text-decoration: none;
  opacity: 0.60;
  transition: opacity 0.2s ease, transform 0.22s ease;
  position: relative;
  padding-bottom: 2px;
  display: inline-block;
}
.vh-nav-sec-link:hover { opacity: 0.88; transform: translateY(-4px); }
.vh-nav-sec-link::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0; right: 0;
  height: 1px;
  background: #6E1D1D;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.2s ease;
}
.vh-nav-sec-link:hover::after { transform: scaleX(1); }

/* ─── About & Support flyout content ─── */
.vh-flyout-about-links {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 4px 0 8px;
}

.vh-flyout-about-link {
  font-family: 'Felix Titling', serif;
  font-size: 12px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: #6E1D1D;
  text-decoration: none;
  opacity: 0.7;
  transition: opacity 0.2s ease;
}
.vh-flyout-about-link:hover { opacity: 1; }

/* ── RIBBON state: hero collapses to a slim 54px bar ── */
.vh-hero.vh-ribbon .vh-hero-inner {
  flex-wrap: nowrap;
  padding: 0 40px;
  height: 54px;
  align-items: center;
  justify-content: flex-start;
  gap: 0;
}

.vh-hero.vh-ribbon .vh-hero-title {
  width: auto;
  font-size: 19px;
  letter-spacing: 2px;
  margin: 0;
  margin-right: auto;   /* push nav to far right */
  white-space: nowrap;
}

.vh-hero.vh-ribbon .vh-cat-nav {
  flex-direction: row;
  align-items: center;
  flex-wrap: nowrap;
  width: auto;
  justify-content: flex-end;
  gap: 16px;
}

/* Ribbon: flatten row wrappers so all items sit in one horizontal line */
.vh-hero.vh-ribbon .vh-nav-row {
  display: contents;   /* removes the wrapper from layout; children become direct flex items */
}

/* Ribbon: hide New Content / Top Content — secondary row not shown in collapsed state */
.vh-hero.vh-ribbon .vh-nav-row--secondary {
  display: none;
}

/* Ribbon: hide flyout chrome */
.vh-hero.vh-ribbon .vh-flyout   { display: none; }
.vh-hero.vh-ribbon .vh-nav-item { flex: 0 0 auto; max-width: none; width: auto; }

/* Ribbon: secondary links inline after a separator */
.vh-hero.vh-ribbon .vh-nav-secondary {
  flex-direction: row;
  gap: 14px;
  border-top: none;
  border-left: 1px solid rgba(180,155,100,0.4);
  padding: 0 0 0 14px;
  margin: 0;
  width: auto;
  align-items: center;
}
.vh-hero.vh-ribbon .vh-nav-sec-link {
  font-size: 11px;
  letter-spacing: 1.2px;
  opacity: 0.45;
}
.vh-hero.vh-ribbon .vh-nav-sec-link::after { bottom: -2px; height: 1px; }

.vh-hero.vh-ribbon .vh-cat-btn,
.vh-hero.vh-ribbon .vh-cat-btn--sm {
  font-size: 11px;
  letter-spacing: 1.5px;
  opacity: 0.55;
  padding: 2px 0;
}

.vh-hero.vh-ribbon .vh-cat-btn.active { opacity: 1; }

.vh-hero.vh-ribbon .vh-cat-btn::after { bottom: -2px; height: 1px; }

/* ── Content area: hidden until category chosen ── */
.vis-home-container {
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.35s ease 0.18s, transform 0.35s ease 0.18s;
  pointer-events: none;
}

.vis-home-container.vh-content-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

@media (max-width: 860px) {
  .vh-hero-title { font-size: 40px; }
  .vh-cat-btn    { font-size: 20px; gap: 32px; }
}

@media (max-width: 560px) {
  .vh-hero-title { font-size: 28px; letter-spacing: 3px; }
  .vh-cat-nav    { gap: 24px; }
  .vh-cat-btn    { font-size: 15px; letter-spacing: 1.5px; }
  .vh-hero.vh-ribbon .vh-hero-inner { padding: 0 16px; }
}

/* ---------------------------------------------------------------------- */
/* HOME — CONTENT COLUMN LABEL                                            */
/* ---------------------------------------------------------------------- */

.vh-col-label {
  font-family: 'Cinzel', serif;
  font-size: 11px;
  font-weight: bold;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: #9a8030;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(180,155,100,0.4);
  display: block;
}

/* ---------------------------------------------------------------------- */
/* HOME (VISUALISATIONS) PAGE — CONTAINER + TILE GRID                    */
/* ---------------------------------------------------------------------- */

.vis-home-container {
  width: 100%;
  max-width: 1300px;
  margin: 0 auto;
  padding: 30px 20px;
  box-sizing: border-box;
}

.vis-tile-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  width: 100%;
}

/* Each tile is an <a> wrapper to keep the whole card clickable. */
.vis-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  aspect-ratio: 1 / 1;
  background: #ede0c4;            /* papyrus tile background */
  border: 1.5px solid rgba(180,155,100,0.45);
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  text-decoration: none;
  color: #0c0301;
  overflow: hidden;
  padding: 18px;
  text-align: center;
  transition: transform 0.25s ease, box-shadow 0.25s ease, background-color 0.25s ease;
}

.vis-tile:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 22px rgba(0,0,0,0.18);
  background-color: #f2e8d0;
}

/* Image layer — sits behind the title.
   Designed for both transparent PNG/SVG drop-ins AND full-bleed photos. */
.vis-tile-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  overflow: hidden;
}

/* Photographs fill the whole tile at low opacity so they read as a faint
   backdrop rather than competing with the title. */
.vis-tile-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.32;
  transition: opacity 0.3s ease, transform 0.4s ease;
}

.vis-tile:hover .vis-tile-image img {
  opacity: 0.5;
  transform: scale(1.04);
}

/* Title sits in the centre of the tile. A soft cream pill behind it
   keeps it readable over the backdrop image. */
.vis-tile-title {
  position: relative;
  z-index: 1;
  font-family: 'Felix Titling', serif;
  font-size: 22px;
  font-weight: bold;
  color: #6E1D1D;
  text-align: center;
  padding: 10px 18px;
  background: rgba(255, 255, 255, 0.78);
  border-radius: 8px;
  box-shadow: 0 0 0 1px rgba(213, 206, 115, 0.55);
  transition: padding 0.25s ease, background 0.25s ease;
}

/* Subtitle reveals just below the centred title on hover. Slides open
   from zero height so the title stays anchored in place. */
.vis-tile-subtitle {
  position: relative;
  z-index: 1;
  font-family: 'Winky Rough', sans-serif;
  font-size: 15px;
  font-style: italic;
  color: #2e2800;
  text-align: center;
  padding: 0 14px;
  max-width: 90%;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: max-height 0.3s ease, opacity 0.3s ease, padding 0.3s ease, margin 0.3s ease;
}

.vis-tile:hover .vis-tile-subtitle {
  max-height: 90px;
  opacity: 1;
  padding: 8px 14px;
  margin-top: 10px;
}

/* Responsive: 2 across on tablets, 1 across on phones. */
@media (max-width: 900px) {
  .vis-tile-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 560px) {
  .vis-tile-grid { grid-template-columns: 1fr; }
}

/* ---------------------------------------------------------------------- */
/* HOME — CATEGORY SECTIONS (tab panels)                                  */
/* ---------------------------------------------------------------------- */

.vis-section--hidden { display: none; }

/* Single-column panel — used by Words / Languages / Other */
.vh-single-col {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  padding: 8px 0;
}

/* Tiles inside single-col panels: auto-fit so they don't stretch
   to absurd widths when there are only 1-2 tiles */
.vh-single-col .vis-tile-grid {
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  max-width: 640px;
}

/* ---------------------------------------------------------------------- */
/* COMING SOON — disabled categories + parked-content panels              */
/* ---------------------------------------------------------------------- */

/* Disabled category button on the home hero (e.g. Words in Stage 1). */
.vh-cat-btn--soon,
.vh-cat-btn--soon:hover {
  opacity: 0.45;
  cursor: default;
  transform: none;
}
.vh-cat-btn--soon::after { display: none; }

/* Small "Coming soon" pill below the disabled category word. */
.vh-soon-tag {
  display: block;
  width: max-content;
  margin: 5px auto 0;
  padding: 3px 11px;
  font-family: 'Winky Rough', sans-serif;
  font-size: 11px;
  font-style: italic;
  letter-spacing: 0.4px;
  text-transform: none;
  color: #f0e6cc;
  background: #6E1D1D;
  border-radius: 20px;
}

/* In the collapsed ribbon the pill would break the single-line layout. */
.vh-hero.vh-ribbon .vh-soon-tag { display: none; }

/* Message shown in the flyout of a disabled category. */
.vh-flyout-soon {
  margin: 0;
  max-width: 220px;
  padding: 12px 16px;
  font-family: 'Winky Rough', sans-serif;
  font-size: 12px;
  font-style: italic;
  line-height: 1.5;
  color: #6b5a18;
  text-align: center;
}

/* Coming-soon panel shown inside a parked category's content section. */
.vis-soon-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 0 auto;
  padding: 52px 28px;
  max-width: 640px;
  background: #ede0c4;
  border: 1.5px dashed rgba(180, 155, 100, 0.6);
  border-radius: 12px;
  text-align: center;
}
.vis-soon-panel-title {
  font-family: 'Felix Titling', serif;
  font-size: 24px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #6E1D1D;
}
.vis-soon-panel-text {
  margin: 0;
  max-width: 460px;
  font-family: 'Winky Rough', sans-serif;
  font-size: 15px;
  font-style: italic;
  line-height: 1.6;
  color: #3a3010;
}

/* Disabled link in the sub-page ribbon navbar (base.html). */
.nav-cat-link--soon,
.nav-cat-link--soon:hover {
  opacity: 0.4;
  cursor: default;
}
.nav-cat-link--soon::after { display: none; }
.nav-soon-tag {
  margin-left: 5px;
  padding: 1px 6px;
  font-size: 8px;
  font-style: italic;
  letter-spacing: 0.5px;
  text-transform: lowercase;
  color: #f0e6cc;
  background: #6E1D1D;
  border-radius: 10px;
  vertical-align: middle;
}

/* ---------------------------------------------------------------------- */
/* MOBILE — navbar + home page tweaks                                     */
/* ---------------------------------------------------------------------- */

@media (max-width: 768px) {
  .nav-inner   { padding: 0 16px; }
  .nav-links   { gap: 16px; }

  .vis-home-container { padding: 18px 14px; }

  .vis-tile-grid  { gap: 16px; }
  .vis-tile-title { font-size: 19px; padding: 8px 14px; }
  .vis-tile-subtitle { font-size: 14px; }

  /* Subtitles always-visible on touch (no hover available). */
  .vis-tile-subtitle {
    max-height: 90px;
    opacity: 1;
    padding: 8px 14px;
    margin-top: 8px;
  }
}

@media (max-width: 480px) {
  .nav-links { gap: 10px; }
  .nav-cat-link { font-size: 10px; }
  .vis-tile-title { font-size: 17px; padding: 7px 12px; }
}

/* ---------------------------------------------------------------------- */
/* MOBILE — DATA-VIS PAGE HEADER + LANG FAM MAP                           */
/* ---------------------------------------------------------------------- */

@media (max-width: 768px) {
  .dv-page-header-row {
    width: 92%;
    margin: 14px auto 8px auto;
  }

  .dv-page-word {
    font-size: 28px;
    line-height: 1.2;
  }

  /* Globe canvas/SVG stage — height is set by JS on mobile (it sizes
     itself to fit the dynamic bottom legend), so no fixed CSS height here. */

  .dv-page-source {
    width: 92%;
    font-size: 13px;
    margin: 8px auto 16px auto;
  }
}

@media (max-width: 480px) {
  .dv-page-word {
    font-size: 24px;
  }
}

/* Mobile speakers-page rules live AFTER the desktop ones (further down
   in the file) so the cascade resolves in the mobile direction inside
   the @media block. Keeping them separated avoids fragile specificity
   gymnastics. */

/* ---------------------------------------------------------------------- */
/* DATA-VIS PAGE HEADER + INFO BOXES                                      */
/* ---------------------------------------------------------------------- */

/* Page-title row is now just a centred wrapper for the <h1>.
   The old top-right info box has moved to a small caption below the viz. */
.dv-page-header-row {
  width: 95%;
  margin: 20px auto 10px auto;
  text-align: center;
}

.dv-page-word {
  margin: 0;
  /* Fluid scale: 28px on small desktop / tablet, up to 42px on wide screens. */
  font-size: clamp(28px, 3.5vw, 42px);
  font-family: 'Felix Titling', serif;
  font-weight: bold;
  line-height: 1.15;
}

/* Small source caption that lives directly below the visualisation.
   Replaces the old top-right info box AND the long bottom-box prose. */
.dv-page-source {
  width: 95%;
  margin: 10px auto 24px auto;
  text-align: center;
  font-family: 'Winky Rough', sans-serif;
  font-size: 14px;
  color: #423c07;
  font-style: italic;
}

.dv-page-source a {
  color: #6E1D1D;
  font-weight: bold;
  font-style: normal;
  text-decoration: none;
  border-bottom: 1px solid rgba(180,155,100,0.4);
  padding-bottom: 1px;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.dv-page-source a:hover {
  color: #d5ce73;
  border-bottom-color: #6E1D1D;
}

/* ---------------------------------------------------------------------- */
/* DATA-VIS PAGE INFO ROW (below visualisation)                          */
/* ---------------------------------------------------------------------- */
/* Two-column layout:
     • LEFT  — explainer prose box, framed in gold like the viz container.
     • RIGHT — stats stack (data source / data quality / data coverage),
               styled like the v1 right-aligned column. */

.dv-page-info-row {
  display: flex;
  width: 95%;
  margin: 16px auto 28px auto;
  gap: 24px;
  align-items: stretch;
  box-sizing: border-box;
}

.dv-page-info-text {
  flex: 1;
  background: rgba(240,230,204,0.55);
  border: 1px solid rgba(180,155,100,0.28);
  border-radius: 6px;
  padding: 14px 18px;
  font-family: 'Winky Rough', sans-serif;
  font-size: 13.5px;
  line-height: 1.6;
  color: #3a3010;
}

.dv-page-info-text p {
  margin: 0;
}

.dv-page-stats-column {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-end;
  justify-content: center;
  min-width: 220px;
  padding: 8px 4px 8px 8px;
  text-align: right;
}

.dv-page-stat {
  display: flex;
  align-items: baseline;
  gap: 10px;
  justify-content: flex-end;
}

.dv-page-stat-label {
  font-family: 'Winky Rough', sans-serif;
  font-size: 13px;
  font-style: italic;
  color: #6b5a18;
  letter-spacing: 0.2px;
}

.dv-page-stat-value {
  font-family: 'Felix Titling', serif;
  font-weight: bold;
  font-size: 18px;
  color: #6E1D1D;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color 0.2s ease, border-color 0.2s ease;
}

/* The data-source value is an <a>; underline on hover so it reads as a
   link without doing so by default. */
a.dv-page-stat-value {
  border-bottom-color: rgba(180,155,100,0.4);
}
a.dv-page-stat-value:hover {
  color: #d5ce73;
  border-bottom-color: #6E1D1D;
}

/* Mobile: stack vertically and left-align the stats so they don't get
   squashed into the right edge. */
@media (max-width: 768px) {
  .dv-page-info-row {
    flex-direction: column;
    width: 92%;
    gap: 12px;
    margin: 12px auto 20px auto;
  }
  .dv-page-info-text {
    font-size: 13px;
    padding: 12px 14px;
  }
  .dv-page-stats-column {
    align-items: flex-start;
    min-width: 0;
    padding: 4px 0;
    text-align: left;
  }
  .dv-page-stat {
    justify-content: flex-start;
  }
  .dv-page-stat-value {
    font-size: 16px;
  }
}

/* ---------------------------------------------------------------------- */
/* DATA-VIS — LANG FAM MAP (SVG + canvas hybrid)                          */
/* ---------------------------------------------------------------------- */

/* Wraps the SVG (sphere/land/chrome) and the canvas (arcs/points).
   Canvas is overlaid on top with pointer-events:none, so drag/click/hover
   pass through to the SVG layer underneath. */
.dv_langfammap-stage {
  position: relative;
  width: 100%;
}

.dv_langfammap-stage svg {
  display: block;
  width: 100%;
  /* Was 800px — left a long empty stretch under the globe + side legends.
     660px is enough for the side-panel legend rows (≈15 × 20 = 300px)
     plus generous chrome and gives the globe ~600px square to play
     with. JS sets the height dynamically on mobile (legend strip + globe). */
  height: 660px;
}

.dv_langfammap-stage canvas {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
}

/* Floating tooltip that follows the cursor when it's over an arc or
   language point. The JS toggles `display` and writes `left` / `top`
   in SVG-frame coordinates. Translated above-and-centred so the
   pointer's tip "anchors" the bottom of the bubble. */
.lang-fam-tooltip {
  position: absolute;
  display: none;
  pointer-events: none;
  z-index: 4;
  padding: 4px 9px;
  background: #f0e6cc;
  color: #423c07;
  border: 1px solid rgba(180,155,100,0.4);
  border-radius: 4px;
  font-family: 'Winky Rough', sans-serif;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  transform: translate(-50%, calc(-100% - 12px));
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
}

/* ── Language search — pinned to the top-right corner of the map stage ── */
/* lang_fam_map.html renders #lang-search inside .dv_langfammap-stage, which
   is position:relative — so absolute placement drops the box into the
   right-hand side panel, just above the "NEW WORLD" heading. Styled to
   match the papyrus palette used across the rest of the site. */
.lang-search {
  position: absolute;
  top: 50px;
  right: 14px;
  width: 167px;
  z-index: 5;
}

.lang-search-input {
  width: 100%;
  box-sizing: border-box;
  padding: 6px 26px 6px 10px;
  font-family: 'Winky Rough', sans-serif;
  font-size: 12px;
  color: #423c07;
  background: #fffdf5;
  border: 1px solid rgba(180, 155, 100, 0.55);
  border-radius: 5px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.lang-search-input::placeholder { color: #9a8a5a; font-style: italic; }
.lang-search-input:focus {
  border-color: #6E1D1D;
  box-shadow: 0 0 0 2px rgba(110, 29, 29, 0.12);
}

/* Clear (×) button — sits inside the input's right edge */
.lang-search-clear {
  position: absolute;
  top: 4px;
  right: 5px;
  width: 18px;
  height: 18px;
  line-height: 16px;
  text-align: center;
  font-size: 14px;
  color: #6E1D1D;
  background: none;
  border: none;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.15s ease;
}
.lang-search-clear:hover { opacity: 1; }

/* Suggestions dropdown */
.lang-search-dropdown {
  list-style: none;
  margin: 3px 0 0;
  padding: 0;
  max-height: 240px;
  overflow-y: auto;
  background: #fffdf5;
  border: 1px solid rgba(180, 155, 100, 0.55);
  border-radius: 5px;
  box-shadow: 0 4px 14px rgba(100, 75, 35, 0.28);
}

.lang-search-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  padding: 6px 10px;
  cursor: pointer;
  border-bottom: 1px solid rgba(180, 155, 100, 0.22);
}
.lang-search-item:last-child { border-bottom: none; }
.lang-search-item:hover,
.lang-search-item[aria-selected="true"] { background: #f0e6cc; }

.lang-search-item-name {
  font-family: 'Winky Rough', sans-serif;
  font-size: 12px;
  color: #423c07;
}
.lang-search-item-fam {
  font-family: 'Winky Rough', sans-serif;
  font-size: 10px;
  font-style: italic;
  color: #6b5a18;
  white-space: nowrap;
}

/* Mobile: no side panels — drop the search into normal flow below the
   globe. position:relative (not static) keeps it a positioning context
   for the absolute clear button. */
@media (max-width: 768px) {
  .lang-search {
    position: relative;
    top: auto;
    right: auto;
    width: auto;
    max-width: 320px;
    margin: 10px auto 4px;
  }
}

/* ---------------------------------------------------------------------- */
/* DATA-VIS — LANG FAM BY SPEAKERS (pie + bar)                            */
/* ---------------------------------------------------------------------- */

/* Cursor-following tooltip shared by the sunburst pie and the bar chart.
   lang_fam_dash.js positions it with clientX / clientY (viewport coords)
   and toggles the `hidden` attribute — so it must be position: fixed.
   (Previously referenced by the template + JS but never defined here,
   which left the tooltip rendering inline in the page flow.) */
.langfampie-tooltip {
  position: fixed;
  z-index: 50;
  pointer-events: none;
  padding: 5px 10px;
  background: #f0e6cc;
  color: #423c07;
  border: 1px solid rgba(180, 155, 100, 0.5);
  border-radius: 5px;
  font-family: 'Winky Rough', sans-serif;
  font-size: 12px;
  line-height: 1.4;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.22);
  max-width: 240px;
}
.langfampie-tooltip[hidden] { display: none; }
.langfampie-tooltip .lftt-sub {
  color: #6b5a18;
  font-style: italic;
}

.dv_langfampie-chart-container {
  position: relative;
  width: 100%;
  min-height: 1050px;
}

#langfambar {
  position: absolute;
  left: 0;
  top: 10px;
  z-index: 1;
  width: 57%;
  height: 1000px;
}

#langfampie {
  position: absolute;
  right: 30px;
  top: 120px;
  z-index: 2;
  width: 41%;
  aspect-ratio: 1 / 1;
  height: auto;
}

.dv_langfampie-viz-container {
  width: 95%;
  min-height: 1000px;
  height: auto;
  margin: 5px auto;
  padding: 5px;
  border: 2px solid rgba(180,155,100,0.4);
  font-size: 16px;
  line-height: 1.5;
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
  box-sizing: border-box;
}

/* Map variant — the lang-fam-map only needs to fit the globe SVG plus
   its rendered legend strip, both of which are sized by the JS. The
   default 1000px min-height was inherited from the speakers page (where
   absolutely-positioned bar + sunburst need that much room) and left a
   long empty stretch underneath the map. Drop the min-height and let
   the inner stage drive the height. */
.dv_langfampie-viz-container--map {
  min-height: 0;
  padding: 8px;
}

.dv_langfampie-toggle-container {
  position: absolute;
  top: 15px;
  right: 50px;
  display: flex;
  gap: 8px;
  z-index: 3;
}

/* Second row of toggles (group variants) sits just below the first. */
.dv_langfampie-toggle-container.dv_langfampie-toggle-container--groups {
  top: 60px;
}

/* Toggle tiles: cream + dark-red when off, blue + cream when on.
   Right-padding is bumped to leave room for the on/off badge in the corner. */
.dv_langfampie-tile {
  position: relative;
  padding: 7px 30px 7px 14px;
  border: 2px solid rgba(180,155,100,0.4);
  border-radius: 6px;
  cursor: pointer;
  font-family: 'Felix Titling', serif;
  font-size: 13px;
  font-weight: bold;
  letter-spacing: 0.3px;
  color: #6E1D1D;
  background: #ffffff;
  user-select: none;
  transition: background-color 0.2s ease,
              color 0.2s ease,
              border-color 0.2s ease,
              box-shadow 0.2s ease,
              transform 0.15s ease;
}

.dv_langfampie-tile:hover {
  background: #f0e6cc;
}

/* Group-toggle variant — slightly different active colour to read as a
   different *kind* of switch from the value toggle above it. */
.dv_langfampie-tile.dv_langfampie-group-tile.active {
  background: #6E1D1D;
  color: #feefc6;
  border-color: #6E1D1D;
  box-shadow: 0 2px 6px rgba(110,29,29,0.25);
}

.dv_langfampie-tile.active {
  background: #5585ae;
  color: #ffffff;
  border-color: #5585ae;
  box-shadow: 0 2px 6px rgba(85,133,174,0.3);
}

.dv_langfampie-tile.active:hover {
  filter: brightness(0.95);
}

/* Small italic on/off badge in the top-right corner.
   Driven entirely by the .active class so it stays in sync with the JS. */
.dv_langfampie-tile::after {
  content: 'off';
  position: absolute;
  top: 3px;
  right: 7px;
  font-family: 'Winky Rough', sans-serif;
  font-size: 9px;
  font-style: italic;
  font-weight: 400;
  letter-spacing: 0.4px;
  text-transform: lowercase;
  opacity: 0.55;
}

.dv_langfampie-tile.active::after {
  content: 'on';
  opacity: 0.95;
}

.dv_langfampie-tile.is-busy {
  pointer-events: none;
  opacity: 0.6;
}

/* ---------------------------------------------------------------------- */
/* MOBILE — LANGUAGES BY SPEAKERS (bar + sunburst stack vertically)       */
/* These rules live AFTER the desktop ones so the cascade picks them up   */
/* without needing higher-specificity selectors.                          */
/* ---------------------------------------------------------------------- */

@media (max-width: 768px) {
  /* Container: drop the desktop 1000px min-height so the page can fit
     itself to the natural stacked-layout height. */
  .dv_langfampie-viz-container {
    min-height: auto;
    padding: 8px;
  }

  /* Chart container becomes a normal block flow rather than an
     absolute-positioning stage. We use CSS `order` on flex children to
     show the sunburst pie ABOVE the bar chart on mobile, since the pie
     is more striking and gives a quick "shape of the data" hit at the
     top of the page. */
  .dv_langfampie-chart-container {
    position: static;
    height: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    text-align: center;
  }

  /* Both rows of toggles flow inline at the top, centred and wrappable.
     `order: 0` keeps them at the very top above both charts. */
  .dv_langfampie-toggle-container {
    position: static;
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
    gap: 6px;
    margin: 4px 0 0 0;
    right: auto;
    top: auto;
    order: 0;
    text-align: center;
  }

  .dv_langfampie-toggle-container.dv_langfampie-toggle-container--groups {
    top: auto;
    margin-top: 2px;
    order: 1;
  }

  /* Slightly smaller toggles to fit two rows comfortably on a phone. */
  .dv_langfampie-tile {
    padding: 6px 26px 6px 12px;
    font-size: 13px;
  }

  /* Sunburst pie: rendered first below the toggles. Full-width but
     capped, kept square via aspect-ratio. We override the desktop
     `position: absolute` so the SVG actually participates in the flex
     order on mobile. */
  #langfampie {
    position: static;
    display: block;
    width: 100%;
    max-width: 380px;
    aspect-ratio: 1 / 1;
    height: auto;
    margin: 6px auto 4px auto;
    right: auto;
    top: auto;
    order: 2;
  }

  /* Bar chart: rendered after the pie. Full-width, scroll-friendly
     height for ~30 bars. */
  #langfambar {
    position: static;
    display: block;
    width: 100%;
    height: 720px;
    margin: 8px 0 4px 0;
    left: auto;
    top: auto;
    order: 3;
  }
}

@media (max-width: 480px) {
  #langfambar {
    height: 640px;
  }

  .dv_langfampie-tile {
    padding: 6px 22px 6px 10px;
    font-size: 12px;
  }
}

/* ---------------------------------------------------------------------- */
/* SUPPORT BUTTON (Ko-fi CTA)                                              */
/* Reusable component, included via templates/_support_button.html.       */
/* ---------------------------------------------------------------------- */

.support-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 16px auto;
  padding: 8px 18px;
  background: #f0a000;
  border: 1.5px solid #f0a000;
  border-radius: 20px;
  color: #1a1a1a;
  text-decoration: none;
  text-align: center;
  box-shadow: 0 2px 8px rgba(240, 160, 0, 0.22);
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.support-btn:hover {
  background: #ffb820;
  border-color: #ffb820;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(240, 160, 0, 0.35);
}

.support-btn:active { transform: translateY(0); }

.support-btn-main {
  font-family: 'Felix Titling', serif;
  font-size: 12px;
  letter-spacing: 0.5px;
  color: #1a1a1a;
  white-space: nowrap;
}

.support-btn-highlight {
  text-shadow: 0 0 6px rgba(255, 247, 216, 0.8);
}

/* Sub-line hidden in compact mode */
.support-btn-sub { display: none; }

/* ---------------------------------------------------------------------- */
/* ABOUT PAGE                                                              */
/* ---------------------------------------------------------------------- */

/* Page-level heading shared by About and any future simple pages */
.vis-home-title {
  font-family: 'Felix Titling', serif;
  font-size: 38px;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: #6E1D1D;
  text-align: center;
  margin: 28px 0 20px;
}

.about-page {
  width: 95%;
  max-width: 820px;
  margin: 0 auto;
  padding: 8px 0 48px;
}

.about-text {
  width: 95%;
  max-width: 680px;
  margin: 8px auto;
  padding: 16px 20px;
  background: rgba(240,230,204,0.6);
  border-radius: 8px;
  border: 1px solid rgba(180,155,100,0.25);
  font-family: 'Winky Rough', sans-serif;
  font-size: 16px;
  line-height: 1.75;
  color: #3a3010;
}

.about-text p {
  margin: 0 0 16px 0;
}

.about-text p:last-child {
  margin-bottom: 0;
}

@media (max-width: 768px) {
  .vis-home-title { font-size: 28px; letter-spacing: 2px; }
  .about-text { font-size: 15px; line-height: 1.65; padding: 12px 14px; }
}

/* ====================================================================== */
/* COOKIE CONSENT BANNER                                                  */
/* Slides up from the bottom of the viewport on first visit. Subtle       */
/* enough not to dominate the page; clear enough that it can't be missed. */
/* ====================================================================== */

.cookie-banner {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%) translateY(140%);
  width: min(92%, 720px);
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 20px;
  background: #f0e6cc;
  border: 1.5px solid #6E1D1D;
  border-radius: 10px;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.25);
  font-family: 'Winky Rough', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: #3a3010;
  z-index: 9999;
  opacity: 0;
  transition: transform 0.32s ease, opacity 0.32s ease;
}

.cookie-banner.cookie-banner-visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.cookie-banner-text strong {
  font-weight: 700;
  color: #6E1D1D;
}

.cookie-banner-text a {
  color: #6E1D1D;
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px solid rgba(180,155,100,0.5);
}

.cookie-banner-text a:hover {
  color: #8a2727;
  border-bottom-color: #6E1D1D;
}

.cookie-banner-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.cookie-btn {
  cursor: pointer;
  padding: 8px 18px;
  border-radius: 6px;
  font-family: 'Felix Titling', serif;
  font-size: 13px;
  letter-spacing: 0.4px;
  border: 1.5px solid #6E1D1D;
  transition: background 0.12s ease, color 0.12s ease,
              transform 0.12s ease, box-shadow 0.12s ease;
}

.cookie-btn-accept {
  background: #6E1D1D;
  color: #f0e6cc;
}
.cookie-btn-accept:hover {
  background: #8a2727;
  border-color: #8a2727;
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(110, 29, 29, 0.30);
}

.cookie-btn-decline {
  background: transparent;
  color: #6E1D1D;
}
.cookie-btn-decline:hover {
  background: rgba(180,155,100,0.2);
}

/* Cookie reset link on the About page */
.cookie-reset-link {
  color: #6E1D1D;
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px solid rgba(180,155,100,0.5);
  cursor: pointer;
  background: none;
  border-top: 0;
  border-left: 0;
  border-right: 0;
  padding: 0;
  font-family: inherit;
  font-size: inherit;
}
.cookie-reset-link:hover {
  color: #8a2727;
}
