/* =========================================================
   Maki's Atelier, v5
   Idea: an illuminated manuscript, kept readable.
   (v3 look + the page structure and code fixes from v4)
   Parchment, sepia ink, red "rubric" ink, a little gold leaf.
   Colors, fonts and spacing live in the variables below.
   ========================================================= */
@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;500;600&family=Crimson+Pro:ital,wght@0,400;0,500;0,600;1,400&family=IM+Fell+English:ital@0;1&family=Cinzel+Decorative:wght@700&display=swap');

:root {
  --paper:      #efe3c8;
  --paper-2:    #e6d6b3;
  --ink:        #2a1d14;
  --muted:      #6b5c47;
  --line:       rgba(42, 29, 20, 0.2);
  --gold:       #b8860b;
  --gold-soft:  rgba(184, 134, 11, 0.55);
  --rubric:     #9c2a1b;   /* red ink: headings marks, links, accents */
  --lapis:      #2a4a80;
  --page-glow:  radial-gradient(ellipse at 50% -5%, #f7edd3 0%, #efe3c8 55%, #e2d1ab 100%);
  --paper-tex:  0.6;

  --display: "IM Fell English", "Iowan Old Style", Georgia, serif;
  --body:    "Crimson Pro", "Iowan Old Style", Georgia, serif;
  --caps:    "Cinzel", "Trajan Pro", Georgia, serif;
  --initial: "Cinzel Decorative", "Cinzel", Georgia, serif;

  --wrap: min(1100px, 100% - 2.5rem);
  --radius: 3px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper:      #17100c;
    --paper-2:    #21170f;
    --ink:        #eadcbc;
    --muted:      #a8977a;
    --line:       rgba(234, 220, 188, 0.18);
    --gold:       #d9a93a;
    --gold-soft:  rgba(217, 169, 58, 0.5);
    --rubric:     #e27a60;
    --lapis:      #6f93d1;
    --page-glow:  radial-gradient(ellipse at 50% -10%, #2d2016 0%, #1a120d 55%, #0f0a07 100%);
    --paper-tex:  0;
  }
}

/* ===== reset + base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--body);
  font-size: 1.22rem;
  line-height: 1.6;
  color: var(--ink);
  background: var(--paper) var(--page-glow) fixed;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-bottom: 5.5rem;       /* room for the music bar */
}
/* parchment texture over the page (light mode only) */
body::before {
  content: "";
  position: fixed; inset: 0; z-index: 50; pointer-events: none;
  background: url('../img/paper.svg');
  opacity: var(--paper-tex);
  mix-blend-mode: multiply;
}

img { max-width: 100%; height: auto; display: block; }
[id] { scroll-margin-top: 5.5rem; }
a { color: inherit; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--rubric); outline-offset: 3px; border-radius: 3px; }
::selection { background: var(--rubric); color: #fff; }

.wrap { width: var(--wrap); margin-inline: auto; }
.skip {
  position: absolute; left: 1rem; top: -4rem; z-index: 100;
  background: var(--ink); color: var(--paper); padding: .5rem 1rem; border-radius: 4px;
}
.skip:focus { top: 1rem; }

/* ===== type ===== */
h1, h2, h3 { font-family: var(--display); font-weight: 400; line-height: 1.05; }
h1 { font-size: clamp(3rem, 8.4vw, 6.4rem); letter-spacing: -0.01em; }
h2 { font-size: clamp(2rem, 4.4vw, 3rem); }
em { font-style: italic; }

/* small capitals label, with a red paragraph mark */
.eyebrow, .caps {
  font-family: var(--caps);
  font-size: .76rem;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--muted);
}
.eyebrow { display: block; margin-bottom: 1.2rem; }
.eyebrow::before { content: "¶"; color: var(--rubric); margin-right: .7em; letter-spacing: 0; font-size: 1rem; }

.prose a, .lede a {
  color: var(--rubric);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: .2em;
}
.prose a:hover, .lede a:hover { text-decoration-thickness: 2px; }

/* ornamental divider (line, curls, diamond) */
.rule {
  height: 22px; width: min(360px, 100%); margin: 1.4rem auto;
  background: var(--gold);
  -webkit-mask: url('../img/rule.svg') center / contain no-repeat;
          mask: url('../img/rule.svg') center / contain no-repeat;
}
.rule.left { margin-inline: 0; }

/* ===== header ===== */
.site-header {
  view-transition-name: header;
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--gold-soft);
  box-shadow: 0 1px 0 var(--paper), 0 2px 0 var(--line);   /* double rule */
}
.site-header .wrap {
  display: flex; align-items: center; justify-content: space-between;
  gap: .6rem 2rem; flex-wrap: wrap; padding-block: .8rem;
}
.brand { display: flex; align-items: center; gap: .75rem; text-decoration: none; }
.brand .mark {
  width: 42px; height: 42px; flex: none;
  background: url('../img/logo-options/a-star.svg') center / contain no-repeat;   /* default; js/logo.js picks one per visit */
  filter: drop-shadow(0 2px 2px rgba(0,0,0,.2)); transition: transform .35s ease;
}
html[data-logo="b-quill"] .brand .mark { background-image: url('../img/logo-options/b-quill.svg'); }
html[data-logo="c-kuki"] .brand .mark { background-image: url('../img/logo-options/c-kuki.svg'); }
.brand:hover .mark { transform: rotate(-6deg) scale(1.06); }
.brand span { font-family: var(--display); font-size: 1.7rem; line-height: 1; }

.nav ul { list-style: none; display: flex; flex-wrap: wrap; align-items: center; }
.nav li + li::before {            /* small gold diamonds between items */
  content: ""; display: inline-block; width: 5px; height: 5px; margin: 0 1rem;
  background: var(--gold); transform: rotate(45deg); vertical-align: middle; opacity: .8;
}
.nav a {
  font-family: var(--caps); font-size: .8rem; letter-spacing: .16em; text-transform: uppercase;
  text-decoration: none; color: var(--muted); padding: .3rem 0; position: relative;
  transition: color .2s;
}
.nav a:hover { color: var(--ink); }
.nav a[aria-current="page"] { color: var(--rubric); }
.nav a[aria-current="page"]::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -3px; height: 1px; background: var(--rubric);
  box-shadow: 0 2px 0 -0px var(--rubric);
}

/* ===== main + entrance ===== */
main { flex: 1; outline: none; overflow-x: clip; padding-block: clamp(2rem, 6vw, 4.5rem) 3rem; }
main > * { animation: rise .8s cubic-bezier(.2, .7, .2, 1) both; }
main > *:nth-child(2) { animation-delay: .08s; }
main > *:nth-child(3) { animation-delay: .16s; }
main > *:nth-child(4) { animation-delay: .24s; }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* ===== home hero ===== */
.hero {
  position: relative; padding-block: 1rem 2rem;
  display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  gap: clamp(1.5rem, 5vw, 4rem); align-items: center;
}
.hero > *:not(.astrolabe) { position: relative; z-index: 1; }
.hero h1 { font-size: clamp(2.9rem, 6.4vw, 5.2rem); }
.hero h1 em { color: var(--rubric); }
.hero .lede { font-size: clamp(1.2rem, 2vw, 1.5rem); max-width: 36ch; margin-top: 1rem; }
.hero-art .piece .mat { padding: .7rem; }
.astrolabe {
  position: absolute; z-index: 0; pointer-events: none;
  right: -3.5rem; top: 50%;
  width: min(620px, 78vw); aspect-ratio: 1;
  margin-top: calc(min(620px, 78vw) / -2);
  background: var(--gold); opacity: .26;
  -webkit-mask: url('../img/astrolabe.svg') center / contain no-repeat;
          mask: url('../img/astrolabe.svg') center / contain no-repeat;
  animation: turn 180s linear infinite;
}
@keyframes turn { to { transform: rotate(360deg); } }

.lede { font-size: clamp(1.3rem, 2.4vw, 1.7rem); line-height: 1.45; max-width: 40ch; margin-top: 1.4rem; }
/* illuminated first letter */
.dropcap::first-letter {
  font-family: var(--initial); font-weight: 700;
  float: left; font-size: 4.4em; line-height: .78;
  padding: .08em .12em 0 0; color: var(--rubric);
  text-shadow: 1px 1px 0 var(--gold-soft);
}

.section { margin-top: clamp(3.5rem, 8vw, 5.5rem); }
.section-head { text-align: center; margin-bottom: 2rem; }
.section-head h2 { font-style: italic; }
.section-head .caps { display: block; margin-top: .6rem; }
.section-head .count { font-family: var(--caps); font-size: .75rem; letter-spacing: .15em; color: var(--rubric); margin-left: .7rem; vertical-align: super; font-style: normal; }
.arrow-link { font-family: var(--caps); font-size: .78rem; letter-spacing: .16em; text-transform: uppercase; text-decoration: none; color: var(--rubric); }
.arrow-link span { display: inline-block; transition: transform .2s; }
.arrow-link:hover span { transform: translateX(5px); }
.center { text-align: center; margin-top: 1.8rem; }

/* ===== the three entrances on the home page ===== */
.doors {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: clamp(2.5rem, 6vw, 4rem);
  border-block: 1px solid var(--gold-soft);
  box-shadow: 0 3px 0 -2px var(--line), 0 -3px 0 -2px var(--line);
}
.doors a {
  display: flex; align-items: baseline; gap: .9rem; padding: 1.5rem 1.8rem;
  text-decoration: none; border-left: 1px solid var(--line); transition: background .25s;
}
.doors a:first-child { padding-left: 0; border-left: 0; }
.doors a:hover { background: color-mix(in srgb, var(--paper-2) 60%, transparent); }
.doors .num { font-family: var(--display); font-size: clamp(1.7rem, 2.8vw, 2.2rem); line-height: 1; color: var(--rubric); min-width: 2.1em; }
.doors .name { font-family: var(--display); font-size: clamp(1.8rem, 3vw, 2.4rem); line-height: 1; }
.doors .go { margin-left: auto; color: var(--rubric); transition: transform .2s; }
.doors a:hover .go { transform: translateX(5px); }

/* ===== gallery: plates that keep each picture's shape ===== */
.wall { display: flex; flex-wrap: wrap; justify-content: center; gap: 2rem 1.5rem; list-style: none; }
.wall li {
  flex-grow: calc(var(--w) / var(--h) * 100);
  flex-basis: calc(var(--w) / var(--h) * 15rem);
  min-width: min(100%, 14rem);
  max-width: calc(var(--w) / var(--h) * 34rem);   /* a plate left alone on its row stops growing at about 34rem tall */
}
.piece { display: block; width: 100%; background: none; border: 0; text-align: center; text-decoration: none; }
.piece .mat {                         /* the picture sits on a mat with a thin gold double rule */
  display: block; padding: .6rem;
  background: var(--paper-2);
  border: 1px solid var(--line);
  box-shadow: inset 0 0 0 3px var(--paper-2), inset 0 0 0 4px var(--gold-soft), 0 16px 28px -20px rgba(40, 20, 5, .65);
  transition: transform .35s ease, box-shadow .35s ease;
}
.piece:hover .mat, .piece:focus-visible .mat { transform: translateY(-4px); }
.piece .frame { display: block; overflow: hidden; background: var(--ink); }
.piece img { width: 100%; transition: transform .7s cubic-bezier(.2, .7, .2, 1); }
.piece:hover img, .piece:focus-visible img { transform: scale(1.04); }
.piece .cap { display: block; margin-top: .8rem; line-height: 1.2; }
.piece .cap b { display: block; font-family: var(--caps); font-weight: 400; font-size: .72rem; letter-spacing: .2em; text-transform: uppercase; color: var(--rubric); }
.piece .cap span { font-family: var(--display); font-style: italic; font-size: 1.25rem; }

/* ===== figure (Kuki, portrait) ===== */
.framed {
  border: 18px solid transparent;
  border-image: url('../img/corner-frame.svg') 24 stretch;
  background: var(--paper-2);
  padding: 0;
}
.framed img { width: 100%; }
.kuki-block {
  display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: clamp(1.5rem, 5vw, 4rem); align-items: center;
}
.kuki-block figure { margin: 0; }
.kuki-block figcaption { text-align: center; margin-top: .5rem; font-family: var(--display); font-style: italic; color: var(--muted); }
.kuki-block h2 { font-size: clamp(2.2rem, 5vw, 3.6rem); line-height: 1.04; }
.kuki-block h2 em { color: var(--rubric); }
.kuki-block .arrow-link { display: inline-block; margin-top: 1.4rem; }

/* ===== inner pages ===== */
.page-head { margin-bottom: clamp(1.5rem, 4vw, 3rem); }
.page-head h1 { font-size: clamp(3rem, 8vw, 5.6rem); }
.tabs { display: flex; flex-wrap: wrap; gap: .6rem 2rem; margin-top: 1.4rem; }
.empty {
  border: 1px solid var(--line); box-shadow: inset 0 0 0 4px var(--paper), inset 0 0 0 5px var(--gold-soft);
  padding: 2.4rem 1.6rem; text-align: center; color: var(--muted);
  font-family: var(--display); font-size: 1.7rem; font-style: italic;
}
.back { display: inline-block; margin-right: .3em; transition: transform .2s; }
.arrow-link:hover .back { transform: translateX(-5px); }
.entries { list-style: none; border-top: 1px solid var(--gold-soft); }
.entries li { display: grid; grid-template-columns: 9rem 1fr; gap: 1rem 2rem; padding: 1.4rem 0; border-bottom: 1px solid var(--line); }
.entries h2 { font-size: 2rem; font-style: italic; }
.entries h2 a { text-decoration: none; }
.entries h2 a:hover { color: var(--rubric); }

.about-grid { display: grid; grid-template-columns: minmax(0, 320px) minmax(0, 1fr); gap: clamp(1.5rem, 5vw, 4rem); align-items: start; }
.portrait-slot { aspect-ratio: 4 / 5; display: grid; place-items: center; margin: 0; background: var(--paper-2); }
.about-grid > figure { margin: 0; }
.prose { max-width: 60ch; }
.prose p { margin-bottom: 1.1rem; }
.prose .placeholder { font-family: var(--display); font-style: italic; font-size: 1.7rem; color: var(--muted); line-height: 1.2; }
.kuki-hero { display: grid; gap: 1.4rem; justify-items: center; text-align: center; }
.kuki-hero .framed { max-width: 720px; width: 100%; }

/* ===== footer ===== */
.site-footer { padding-block: 1rem 1.8rem; color: var(--muted); text-align: center; }
.site-footer .rule { margin-top: 0; }
.site-footer .wrap { display: flex; justify-content: space-between; gap: .6rem 2rem; flex-wrap: wrap; }
.site-footer .foot-top { justify-content: center; margin-bottom: 1rem; }
.foot-nav { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem 1.6rem; }
.foot-nav a { font-family: var(--caps); font-size: .76rem; letter-spacing: .16em; text-transform: uppercase; text-decoration: none; color: var(--muted); }
.foot-nav a:hover { color: var(--rubric); }

/* ===== music bar ===== */
.player {
  view-transition-name: player;
  position: fixed; left: max(1rem, env(safe-area-inset-left)); bottom: max(1rem, env(safe-area-inset-bottom)); z-index: 40;
  display: flex; align-items: center; gap: .15rem; padding: .3rem;
  background: color-mix(in srgb, var(--paper-2) 94%, transparent);
  backdrop-filter: blur(8px);
  border: 1px solid var(--gold-soft); border-radius: 999px;
  box-shadow: inset 0 0 0 2px var(--paper-2), inset 0 0 0 3px var(--line), 0 10px 26px -12px rgba(30, 15, 5, .55);
  font-family: var(--caps); font-size: .68rem; letter-spacing: .12em; text-transform: uppercase;
  max-width: calc(100vw - 2rem);
}
.player[hidden] { display: none; }
.player .title { padding: 0 .8rem 0 .5rem; max-width: 15rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player button {
  display: grid; place-items: center; width: 36px; height: 36px; flex: none;
  background: none; border: 0; border-radius: 50%; color: var(--ink); transition: background .15s, color .15s;
}
.player button:hover { background: var(--line); }
.player .play { background: var(--rubric); color: #fff; }
.player .play:hover { background: color-mix(in srgb, var(--rubric) 80%, #000); }
.player button[aria-pressed="true"] { color: var(--muted); }
.player svg { width: 16px; height: 16px; fill: currentColor; }
.player .bars { display: none; align-items: flex-end; gap: 2px; height: 14px; margin-left: .55rem; }
.player[data-state="playing"] .bars { display: flex; }
.player .bars i { width: 3px; background: var(--gold); border-radius: 1px; animation: bar .9s ease-in-out infinite; }
.player .bars i:nth-child(2) { animation-delay: .18s; }
.player .bars i:nth-child(3) { animation-delay: .36s; }
@keyframes bar { 0%, 100% { height: 3px; } 50% { height: 14px; } }

/* ===== lightbox ===== */
#lightbox { border: 0; padding: 0; background: transparent; width: 100%; height: 100%; max-width: none; max-height: none; color: var(--ink); }
#lightbox::backdrop { background: color-mix(in srgb, var(--paper) 92%, transparent); backdrop-filter: blur(8px); }
.lb { height: 100%; display: grid; grid-template-rows: minmax(0, 1fr) auto; gap: .8rem; padding: clamp(.8rem, 3vw, 2rem); }
.lb figure { display: grid; place-items: center; min-height: 0; }
.lb img {
  max-width: 100%; max-height: calc(100vh - 8.5rem); max-height: calc(100dvh - 8.5rem); object-fit: contain;
  border: 18px solid transparent; border-image: url('../img/corner-frame.svg') 24 stretch;
  background: var(--paper-2); box-shadow: 0 30px 70px -30px rgba(30, 15, 5, .75);
}
.lb-bar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.lb-bar .caps { color: var(--ink); }
.lb button.round {
  display: grid; place-items: center; width: 44px; height: 44px;
  background: var(--paper-2); border: 1px solid var(--gold-soft); border-radius: 50%;
}
.lb button.round:hover { background: var(--rubric); color: #fff; border-color: var(--rubric); }
.lb button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.lb .controls { display: flex; gap: .5rem; }

/* ===== page transitions ===== */
@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .3s; }

/* ===== small screens ===== */
@media (max-width: 760px) {
  .kuki-block, .about-grid, .hero { grid-template-columns: 1fr; }
  .hero-text { text-align: left; }
  .doors { grid-template-columns: 1fr; }
  .doors a, .doors a:first-child { padding: 1.1rem 0; border-left: 0; }
  .doors a + a { border-top: 1px solid var(--line); }
  .site-footer .wrap { flex-direction: column; align-items: center; text-align: center; }
  .foot-nav { justify-content: center; }
  .entries li { grid-template-columns: 1fr; gap: .3rem; }
  .player { right: 1rem; }
  .player .title { flex: 1; max-width: none; }
  .brand span { font-size: 1.45rem; }
  .nav li + li::before { margin: 0 .6rem; }
  .nav a { font-size: .72rem; letter-spacing: .12em; }
  .astrolabe { opacity: .18; }
}

/* ===== less motion ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
}

/* ===== YouTube panel (shown above the music bar while a YouTube track is current) ===== */
.yt-panel {
  view-transition-name: ytpanel;
  position: fixed; z-index: 39;
  left: max(1rem, env(safe-area-inset-left));
  bottom: calc(max(1rem, env(safe-area-inset-bottom)) + 3.4rem);
  box-sizing: content-box; width: 200px; height: 200px;        /* the video itself is exactly 200 x 200, the smallest YouTube allows */
  padding: .35rem; background: var(--paper-2);
  border: 1px solid var(--gold-soft);
  box-shadow: inset 0 0 0 2px var(--paper-2), inset 0 0 0 3px var(--line), 0 14px 30px -14px rgba(30, 15, 5, .6);
}
.yt-panel[hidden] { display: none; }
.yt-panel iframe { width: 100%; height: 100%; display: block; border: 0; background: #000; }
