/* =========================================================
   DECADE — a love letter, in pixels. (러브장 vibes.)
   Left nav (fixed) + right content pane, no page reloads.

   THREE FONT SLOTS:
   --font-pixel : Galmuri9 — sidebar (logo, nav, folds) and all
                  page/section titles (h1/h2).
   --font-body  : Ycomputer — actual reading text: paragraphs,
                  bylines, notes, meta text.
   --font-emoji : Mona12 — used only for specific pixel-emoji glyphs
                  (the key icon, the homepage sparkles) via .pixel-emoji.
   All three are self-hosted from /fonts, no external font CDN.
   ========================================================= */

@font-face {
  font-family: 'Galmuri9';
  src: url('fonts/Galmuri9.woff2') format('woff2');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Ycomputer';
  src: url('fonts/Ycomputer.woff2') format('woff2');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}
/* Ycomputer ships blank glyphs for a few syllables this fandom uses
   ("섷" and "엩"), so those characters are pulled from Galmuri9 instead.
   Declared after the real Ycomputer face so it wins for these code
   points only. */
@font-face {
  font-family: 'Ycomputer';
  src: url('fonts/Galmuri9-hangul-fix.woff2') format('woff2');
  unicode-range: U+C137, U+C5E9;
  size-adjust: 88%; /* Galmuri9 glyphs run ~12% larger than Ycomputer's; the font file is a 2-glyph subset re-centred and re-spaced to sit on Ycomputer's baseline */
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Mona12';
  src: url('fonts/Mona12.woff2') format('woff2');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

:root {
  /* -- love-letter palette: cream paper, blush envelope, plum ink,
     lemon-lime pop (Y2K 러브장 sticker-diary combo) -- */
  --bg:          #fff6f2;   /* warm cream page */
  --paper:       #fffaf7;   /* slightly whiter card/paper surface */
  --panel:       #ffd9e6;   /* soft pink sidebar / envelope */
  --ink:         #55293b;   /* deep plum-maroon — reads easily on cream */
  --ink-dim:     #a9728a;   /* dusty rose-brown for secondary text */
  --accent:      #e0507a;   /* rose red — titles, active states */
  --accent-2:    #cbe552;   /* lemon-lime — hover, secondary highlight, coils */
  --highlight:   #ffe1ec;   /* pale pink highlight background */
  --border:      #f0b8cc;   /* dashed dividers, stitched-envelope look */
  --link:        #d1477c;
  --link-visited:#8a9a2f;   /* olive-lime, keeps the purple out entirely */
  --shadow:      rgba(224, 80, 122, 0.18);

  --font-pixel: 'Galmuri9', 'Courier New', Courier, monospace;
  --font-body:  'Ycomputer', Georgia, 'Times New Roman', serif;
  --font-emoji: 'Mona12', sans-serif;

  --sidebar-w: 260px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  background-color: var(--bg);
  background-image: radial-gradient(var(--border) 1px, transparent 1px);
  background-size: 24px 24px;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.75;
}

a { color: var(--link); text-decoration: underline; }
a:visited { color: var(--link-visited); }
a:hover   { color: var(--accent); }

hr {
  border: none;
  border-top: 2px dashed var(--border);
  margin: 1.3em 0;
}

/* ---- pixel-corner "sticker" frame, used on boxes throughout ---- */
.pixel-frame {
  clip-path: polygon(
    0 8px, 8px 8px, 8px 0,
    calc(100% - 8px) 0, calc(100% - 8px) 8px, 100% 8px,
    100% calc(100% - 8px), calc(100% - 8px) calc(100% - 8px), calc(100% - 8px) 100%,
    8px 100%, 8px calc(100% - 8px), 0 calc(100% - 8px)
  );
}

/* ---- hand-drawn pixel heart (pure CSS, no image needed) ---- */
.pixel-heart {
  display: inline-block;
  width: 3px;
  height: 3px;
  background: transparent;
  box-shadow:
    3px 0 var(--accent), 6px 0 var(--accent), 12px 0 var(--accent), 15px 0 var(--accent),
    0 3px var(--accent), 3px 3px var(--accent), 6px 3px var(--accent), 9px 3px var(--accent),
      12px 3px var(--accent), 15px 3px var(--accent), 18px 3px var(--accent),
    0 6px var(--accent), 3px 6px var(--accent), 6px 6px var(--accent), 9px 6px var(--accent),
      12px 6px var(--accent), 15px 6px var(--accent), 18px 6px var(--accent),
    3px 9px var(--accent), 6px 9px var(--accent), 9px 9px var(--accent), 12px 9px var(--accent), 15px 9px var(--accent),
    6px 12px var(--accent), 9px 12px var(--accent), 12px 12px var(--accent),
    9px 15px var(--accent);
  margin: 0 21px 15px 0; /* reserve the drawn shape's footprint */
}
.pixel-heart--sm { transform: scale(0.6); margin: -4px 4px -8px -4px; vertical-align: middle; }

/* ---- pixel emoji glyphs (Mona12), used for the key icon + homepage
   sparkles instead of the OS's native emoji rendering ---- */
.pixel-emoji {
  font-family: var(--font-emoji);
  font-style: normal;
  line-height: 1;
}

/* ---- layout ---- */
#layout {
  display: flex;
  min-height: 100vh;
  align-items: stretch;
}

#sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--panel);
  border-right: 3px dashed var(--accent-2);
  padding: 24px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  font-family: var(--font-pixel);
}

#content {
  flex: 1 1 auto;
  padding: 48px 52px;
  max-width: 780px;
}

/* ---- sidebar: logo ---- */
.logo {
  text-align: center;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 2px dashed var(--accent-2);
}
.pixel-heart { margin-left: auto; margin-right: auto; }
.logo-title {
  color: var(--accent);
  font-size: 1.5em;
  letter-spacing: 3px;
}
.logo-sub {
  font-size: 0.55em;
  color: var(--ink-dim);
  letter-spacing: 1px;
  margin-top: 6px;
  font-family: var(--font-body);
  font-style: italic;
}

/* ---- sidebar: nav tree (pixel font throughout) ----
   Each link is a flex row: a marquee box (which clips/scrolls the
   label if it's too long for the menu) plus optional fixed badges
   (like the 🔒 on a locked work) that never get clipped or scrolled. */
.nav-tree {
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1 1 auto;
}
.nav-tree > li { margin-bottom: 8px; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  color: var(--ink);
  text-decoration: none;
  border: 1px solid transparent;
}
.nav-link:visited { color: var(--ink); }
.nav-link:hover {
  color: var(--ink);
  background: var(--accent-2);
}
.nav-link.active {
  color: var(--paper);
  background: var(--accent);
  border-color: var(--ink);
}

/* foldable TEXT / PIC sections via native <details> */
details.nav-fold {
  border: 2px solid var(--accent-2);
  margin-bottom: 4px;
  background: var(--paper);
}
details.nav-fold summary {
  cursor: pointer;
  padding: 7px 10px;
  color: var(--accent);
  letter-spacing: 2px;
  list-style: none;
  user-select: none;
}
details.nav-fold summary::-webkit-details-marker { display: none; }
details.nav-fold summary::before {
  content: '♡ ';
  color: var(--ink-dim);
}
details.nav-fold[open] summary::before {
  content: '♥ ';
  color: var(--accent);
}
details.nav-fold summary:hover { background: var(--highlight); }

details.nav-fold ul {
  list-style: none;
  margin: 0;
  padding: 4px 0 8px 0;
}
details.nav-fold ul li a {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px 6px 24px;
  font-size: 0.85em;
  color: var(--ink-dim);
  text-decoration: none;
}
details.nav-fold ul li a:hover {
  color: var(--ink);
  background: var(--accent-2);
}
details.nav-fold ul li a.active {
  color: var(--paper);
  background: var(--accent);
}

/* ---- menu-label marquee: clips a nav label to one line and, only if
   it's actually too long for the menu, scrolls it — paused on hover.
   Markup: a.nav-link > span.marquee-box > span.marquee-track > span.marquee-text
   marquee.js measures overflow and adds .is-marquee + clones the text. ---- */
.marquee-box {
  overflow: hidden;
  white-space: nowrap;
  min-width: 0;
  flex: 1 1 auto;
  position: relative;
}
.marquee-track {
  display: inline-flex;
  white-space: nowrap;
  will-change: transform;
}
.marquee-text { display: inline-block; }
.marquee-clone { margin-left: 48px; }
.is-marquee .marquee-track {
  animation: marquee-scroll var(--marquee-duration, 12s) linear infinite;
}
.nav-link:hover .marquee-track {
  animation-play-state: paused;
}
@keyframes marquee-scroll {
  from { transform: translateX(0); }
  to   { transform: translateX(var(--marquee-shift, -50%)); }
}

.sidebar-footer {
  margin-top: 20px;
  padding-top: 14px;
  border-top: 2px dashed var(--accent-2);
  font-size: 0.75em;
  color: var(--ink-dim);
  text-align: center;
}
.footer-icons {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 8px;
}
.key-link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  opacity: 0.85;
  font-size: 1.3em;
}
.key-link:hover { opacity: 1; }
.key-link:hover .pixel-emoji { transform: scale(1.15); }
.blink { animation: blink 1.1s steps(1) infinite; color: var(--accent); font-size: 1.1em; }
@keyframes blink { 50% { opacity: 0.15; } }

/* ---- locked-work tag in the nav (fixed, never clipped/scrolled) ---- */
.lock-tag {
  font-family: var(--font-emoji);
  font-style: normal;
  color: var(--accent);
  font-size: 0.85em;
  flex: 0 0 auto;
}

/* ---- content pages ---- */
.page { display: none; }
.page.active { display: block; }

h1 {
  font-family: var(--font-pixel);
  color: var(--accent);
  letter-spacing: 1px;
  margin-top: 0;
  line-height: 1.5;
}
h2 {
  font-family: var(--font-pixel);
  color: var(--accent);
  letter-spacing: 1px;
}

.meta, .crumb {
  font-family: var(--font-pixel);
  color: var(--ink-dim);
  font-size: 0.8em;
  letter-spacing: 1px;
}
.byline { color: var(--ink-dim); font-style: italic; }
.hint { color: var(--ink-dim); font-size: 0.9em; }
.signoff {
  margin-top: 2.5em;
  font-style: italic;
  color: var(--accent);
}

/* ---- homepage sparkle field: random ✨⭐️🌟💫 in the pixel-emoji font,
   scattered at random positions across the page and blinking on and
   off like an old-school <blink> page. Sits BEHIND the actual text
   (z-index:-1 within #page-home's own stacking context) so it never
   competes with reading — it just peeks through the gaps around
   letters and lines. #page-home is the positioning anchor; sparkle.js
   sets each glyph's own top/left/size inline. ---- */
#page-home { position: relative; z-index: 0; }
.home-center { text-align: center; }
.home-label { font-size: 1em; margin: 2.2em 0 0.3em; }
.home-center p { margin: 0.3em 0; }
.home-legal { margin-top: 3.5em !important; font-size: 0.85em; color: var(--ink-dim); }
.sparkle-field {
  position: absolute;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none; /* never blocks clicks/selection on the text above */
}
.sparkle-field .pixel-emoji {
  position: absolute;
  opacity: 0.8;
}
.blink-emoji {
  display: inline-block;
  animation-name: blink;
  animation-timing-function: steps(1);
  animation-iteration-count: infinite;
}

/* every source paragraph is its own <p>, indented one full-width
   character (2 bytes); .cont paragraphs follow their neighbour with no
   gap, the way lines run in a printed novel */
.work-body p { margin: 0; text-indent: 1em; }
.work-body p:not(.cont) { margin-top: 1.1em; }
.work-body p:last-child { margin-bottom: 1.1em; }
.work-body p.scene-break, .work-body p.hint { text-indent: 0; }
/* explicit markers (-, *, +1, /) and blank-line breaks both get generous
   room so the parts read as clearly separate */
.work-body p.scene-break { margin-top: 3em; margin-bottom: 3em; }
/* blank-line break: --n = number of empty lines in the source, one line
   height each, plus extra margin on both sides */
.work-body .gap { height: calc(var(--n) * 1.75em); margin: 1.2em 0; }
.work-body .gap + p { margin-top: 0; }
.work-body .gap + .video-wrapper, .work-body .video-wrapper + .gap { margin-top: 0; }
.work-body p.byline { text-indent: 0; margin: 1em 0; }
/* right-aligned note under the title, byline-styled, with one extra blank line below */
.work-body p.note-right { text-indent: 0; text-align: right; margin-bottom: 2.85em; }
.work-body h1 { margin-top: 60px; }

/* room between the title block and where the text starts */
.page.work > hr, .locked-page > hr { margin-bottom: 3.5em; }

/* breathing room below the last line of every work / gallery page */
.page.work { padding-bottom: 70px; }
.locked-page { padding-bottom: 70px; }

.video-wrapper {
    position: relative;
    height: 0;
    /* 16:9 aspect ratio (360/560 from the embed code) via the classic
       padding-bottom hack, so the iframe (position:absolute, height:100%)
       actually has something to fill — the pasted 40px/40px fixed padding
       only ever produced an 80px-tall box, too short to show anything */
    padding-bottom: 56.25%;
    margin-top: 60px;
    margin-bottom: 60px;
}

/* a scene break within a work — reuses whatever marker the author used
   in their own manuscript (an em dash, an asterisk, a "+2.4"-style
   count, a plain middle-dot row, ...) rather than imposing one look */
.scene-break {
  text-align: center;
  margin: 2em 0;
  color: var(--ink-dim);
  font-family: var(--font-pixel);
  letter-spacing: 3px;
}

/* ---- PIC gallery: every image spans the full width of the content
   column, stacked in order. A generous gap between 008 and 009 marks
   the passage of time, per the three special characters. ---- */
.art-gallery {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.art-gallery img {
  width: 100%;
  height: auto;
  display: block;
}
.time-divider {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin: 100px 0;
  color: var(--ink-dim);
  font-size: 1.3em;
}

.art-frame {
  border: 3px dashed var(--accent-2);
  background: var(--paper);
  padding: 70px 20px;
  text-align: center;
  color: var(--ink-dim);
  letter-spacing: 2px;
  font-family: var(--font-pixel);
}
.art-frame img { max-width: 100%; display: block; margin: 0 auto; }

.jump-ps { margin-top: 2em; }
.jump-ps a { font-size: 0.9em; }

/* P.S. page — each note styled like a little pulled-out letter card */
.ps-entry {
  background: var(--paper);
  border: 2px dashed var(--border);
  padding: 20px 24px;
  margin: 0 0 22px 0;
}
.ps-entry h2 {
  font-size: 1em;
  margin: 0 0 8px 0;
}
.ps-who { color: var(--ink-dim); font-weight: normal; font-size: 0.8em; font-family: var(--font-body); font-style: italic; }
.ps-entry.flash { background: var(--highlight); border-color: var(--accent); }

/* ---- 러브장 spring-binder strip: a row of little punched rings across
   the top of a text-containing div, like a page torn from a spiral
   notebook. Used on #content and the standalone .locked-page. ---- */
.binder-top {
  position: relative;
  margin-top: 20px;
  padding-top: 34px;
}
.binder-top::before {
  content: '';
  position: absolute;
  top: 0;
  left: 12px;
  right: 12px;
  height: 20px;
  background-image: radial-gradient(circle, var(--bg) 0 4px, var(--accent-2) 4px 6px, transparent 6px);
  background-size: 28px 20px;
  background-repeat: repeat-x;
  background-position: 6px 0;
  pointer-events: none;
}

/* ---- standalone pages outside the app shell (protected/*.html) — no sidebar, just the content column centered ---- */
.locked-page {
  max-width: 720px;
  margin: 0 auto;
  padding: 56px 24px;
}
.back-link {
  display: inline-block;
  margin-bottom: 32px;
  font-family: var(--font-pixel);
  font-size: 0.85em;
}

/* ---- mobile menu toggle ---- */
#menuToggle {
  display: none;
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 20;
  background: var(--panel);
  color: var(--accent);
  border: 2px solid var(--accent-2);
  font-family: var(--font-pixel);
  padding: 9px 14px;
  cursor: pointer;
}

@media (max-width: 760px) {
  #menuToggle { display: block; }

  #layout { flex-direction: column; }

  #sidebar {
    position: fixed;
    inset: 0 20% 0 0;
    height: 100vh;
    width: auto;
    z-index: 15;
    transform: translateX(-105%);
    transition: transform 0.15s ease-out;
  }
  #sidebar.open { transform: translateX(0); }

  #content {
    padding: 72px 22px 40px;
    max-width: 100%;
  }
}
