/* ============================================================
   GLOBAL RESET & BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { min-height: 100vh; width: 100%; }

body {
  font-family: 'Nunito', 'Inter', sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: #222;
  min-height: 100vh;
  background-image: url('assets/wall.webp');
  background-size: cover;
  background-repeat: no-repeat;
  background-position: center;
  background-attachment: fixed;
}

hr { border: none; height: 1px; margin: 0; padding: 0; background: rgba(255,255,255,0.4); }
#layout-footer { margin-top: auto; width: 100%; }
footer { text-align: center; padding: 24px 0 16px; }
footer img { image-rendering: pixelated; }
.row { display: flex; flex-wrap: wrap; justify-content: center; }
.row img { image-rendering: pixelated; margin: 4px; }

/* Nothing inside a box is ever wider than the box */
.content-box img, .page-container img { max-width: 100%; height: auto; }


/* ============================================================
   PAGE WRAP & BODY LAYOUT
   ============================================================ */
.page-wrap {
  max-width: 1300px;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.body-layout {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

/* Main content area (right of sidebar) */
.main-content {
  flex: 1;
  min-width: 0;
}


/* ============================================================
   SITE TITLE (injected by layout.js into #layout-header)
   ============================================================ */
.top-header { padding: 6px 0 4px; margin: 0; text-align: center; }
.top-header svg { display: block; overflow: visible; }
.top-header-link { display: block; text-decoration: none; }

.site-title {
  font-family: 'Press Start 2P', cursive;
  font-size: 28px;
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  letter-spacing: 1px;
  padding: 10px 0 6px;
  align-items: center;
  justify-content: center;
}
.site-title a {
  text-decoration: none;
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  align-items: center;
  justify-content: center;
}
.site-title span {
  display: inline-block;
  text-shadow: 2px 0 #000,-2px 0 #000,0 2px #000,0 -2px #000,
               1px 1px #000,-1px -1px #000,1px -1px #000,-1px 1px #000;
}
.site-title span:nth-child(6n+1) { color: #ff8fab }
.site-title span:nth-child(6n+2) { color: #ffd166 }
.site-title span:nth-child(6n+3) { color: #caffbf }
.site-title span:nth-child(6n+4) { color: #9bf6ff }
.site-title span:nth-child(6n+5) { color: #bdb2ff }
.site-title span:nth-child(6n+6) { color: #ffc6ff }


/* ============================================================
   LEFT SIDEBAR (injected by layout.js into #layout-sidebar)
   ============================================================ */
.sidebar {
  width: 200px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: sticky;
  top: 10px;
}

.sidebar-card {
  background: rgba(255,255,255,0.55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.7);
  border-radius: 16px;
  padding: 12px;
  color: #4a2060;
  font-size: 12px;
  line-height: 1.6;
  text-align: left;
}

.sidebar-card h3 {
  font-family: 'Press Start 2P', cursive;
  font-size: 9px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #fff;
  text-shadow: 1px 1px 0 #000,-1px -1px 0 #000,1px -1px 0 #000,-1px 1px 0 #000;
  margin-bottom: 8px;
}

.sidebar-card img { width: 100%; image-rendering: pixelated; margin-bottom: 6px; }

/* Nav list inside sidebar */
.sidebar-card ul { list-style: none; padding: 0; }
.sidebar-card li {
  position: relative;
  padding-left: 16px;
  font-size: 12px;
  line-height: 1.8;
}
.sidebar-card li::before {
  content: "★";
  position: absolute;
  left: 0;
  font-size: 14px;
  line-height: 1.4;
  text-shadow: 1px 0 #000,-1px 0 #000,0 1px #000,0 -1px #000;
}
.sidebar-card li:nth-child(6n+1)::before { color: #ff8fab }
.sidebar-card li:nth-child(6n+2)::before { color: #ffd166 }
.sidebar-card li:nth-child(6n+3)::before { color: #caffbf }
.sidebar-card li:nth-child(6n+4)::before { color: #9bf6ff }
.sidebar-card li:nth-child(6n+5)::before { color: #bdb2ff }
.sidebar-card li:nth-child(6n+6)::before { color: #ffc6ff }

.sidebar-card a {
  text-decoration: none;
  color: #3a1850;
  transition: color 0.15s;
}
.sidebar-card a:hover { color: #9040c0; text-decoration: underline; }
.sidebar-card a[aria-current="page"] { color: #9040c0; font-weight: 700; }

/* Non-list links (Clubs, Other Links) */
.sidebar-links { display: flex; flex-direction: column; gap: 4px; }
.sidebar-links a {
  font-size: 12px;
  color: #3a1850;
  text-decoration: none;
  line-height: 1.6;
}
.sidebar-links a:hover { color: #9040c0; text-decoration: underline; }
.sidebar-links img { width: auto; height: 12px; vertical-align: middle; image-rendering: pixelated; margin-bottom: 0; }
.sidebar-links img.club-button { width: 88px; height: 31px; }
.sidebar-links a:has(.club-button) { white-space: nowrap; }

/* Top link */
.sidebar-top-link { text-align: center; margin-top: 4px; }
.sidebar-top-link a {
  font-family: 'Press Start 2P', cursive;
  font-size: 9px;
  color: #3a1850;
  text-decoration: none;
}
.sidebar-top-link a:hover { color: #9040c0; }


/* ============================================================
   CONTENT BOXES (frosted glass)
   ============================================================ */
.page-container,
.content-box {
  width: 100%;
  box-sizing: border-box;
  padding: 20px;
  border-radius: 18px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.1);
  border: 1px solid rgba(255,255,255,0.65);
  background: rgba(255,255,255,0.5);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #4a2060;
  text-align: center;
}

.page-wrapper {
  display: flex;
  flex-direction: column;
  gap: 20px;
}


/* ============================================================
   SECTION TITLE (bouncing rainbow letters)
   ============================================================ */
.section-title { text-align: center; margin-bottom: 12px; }
.section-title .gap { display: inline-block; width: 8px; }

.section-title span, .letter {
  display: inline-block;
  font-family: 'Press Start 2P', cursive;
  font-size: 16px;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: bold;
  text-shadow: 2px 0 #000,-2px 0 #000,0 2px #000,0 -2px #000,
               1px 1px #000,-1px -1px #000,1px -1px #000,-1px 1px #000;
  animation: letterBounce 1.2s ease forwards infinite;
  animation-delay: calc(var(--i) * 0.12s);
}
.section-title span:nth-child(6n+1), .letter:nth-child(6n+1) { color: #ff8fab }
.section-title span:nth-child(6n+2), .letter:nth-child(6n+2) { color: #ffd166 }
.section-title span:nth-child(6n+3), .letter:nth-child(6n+3) { color: #caffbf }
.section-title span:nth-child(6n+4), .letter:nth-child(6n+4) { color: #9bf6ff }
.section-title span:nth-child(6n+5), .letter:nth-child(6n+5) { color: #bdb2ff }
.section-title span:nth-child(6n+6), .letter:nth-child(6n+6) { color: #ffc6ff }

@keyframes letterBounce {
  0%   { transform: translateY(0); }
  20%  { transform: translateY(-8px); }
  40%  { transform: translateY(2px); }
  60%  { transform: translateY(0); }
  100% { transform: translateY(0); }
}


/* ============================================================
   PAGE H2 TITLES
   ============================================================ */
.page-container h2, .content-box h2 {
  font-family: 'Press Start 2P', cursive;
  font-size: 14px;
  letter-spacing: 1px;
  text-transform: uppercase;
  line-height: 1.4;
  text-align: center;
  color: #fff;
  text-shadow: 2px 0 #000,-2px 0 #000,0 2px #000,0 -2px #000,
               1px 1px #000,-1px -1px #000,1px -1px #000,-1px 1px #000;
  margin-bottom: 8px;
}


/* ============================================================
   STARS & CLOUDS ANIMATION (pages that use them)
   ============================================================ */
@keyframes twinkle {
  0%,100% { opacity: var(--lo,0.3); transform: scale(1); }
  50%      { opacity: var(--hi,1);  transform: scale(1.4); }
}
@keyframes floatCloud {
  from { transform: translateX(var(--start,110vw)); }
  to   { transform: translateX(-400px); }
}

#stars, #clouds {
  position: fixed; top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none; z-index: 0;
  overflow: hidden;
}
.sky-star {
  position: absolute; border-radius: 50%; background: #fff;
  --hi: 1;
  animation: twinkle 3s ease-in-out infinite;
}
.sky-cloud {
  position: absolute; left: 0;
  animation: floatCloud 38s linear infinite;
}
.sky-cloud .puff, .sky-cloud i {
  position: relative; display: block;
  background: rgba(255,255,255,0.78);
  border-radius: 50px;
}
.sky-cloud i { position: absolute; border-radius: 50%; }

/* Page content always sits above the sky */
.page-wrap { position: relative; z-index: 1; }


/* ============================================================
   GALLERY SHELVES (gallery.js)
   ============================================================ */
.shelf { --max: 200px; }
.shelf .row { align-items: center; }
.shelf img {
  width: auto; height: auto;
  max-width: min(var(--max), 100%);
  max-height: var(--max);
  vertical-align: middle;
}
.gallery-section + .gallery-section {
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid rgba(255,255,255,0.4);
}
.content-box h2 + hr, .page-container h2 + hr,
.section-title + hr { margin-bottom: 20px; }
img.pixel { display: block; margin: 12px auto; image-rendering: pixelated; }


/* ============================================================
   SPARKLE TRAIL + BACK TO TOP
   ============================================================ */
.sparkle-bit {
  position: fixed; left: 0; top: 0;
  pointer-events: none; user-select: none;
  line-height: 1; visibility: hidden;
  z-index: 999999;
  will-change: transform, opacity;
}

.to-top {
  position: fixed; right: 24px; bottom: 24px; z-index: 9999;
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.7);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.8);
  border-radius: 50%;
  color: #7030a0; font-size: 18px; font-weight: 700; text-decoration: none;
  box-shadow: 0 2px 10px rgba(120,60,180,0.2);
  opacity: 0; visibility: hidden; transform: translateY(8px);
  transition: opacity .2s ease, transform .2s ease, background-color .2s ease, visibility .2s;
}
.to-top.is-visible { opacity: 1; visibility: visible; transform: none; }
.to-top:hover { background: rgba(255,255,255,0.95); transform: translateY(-2px); }

/* Freeze button (sits above back-to-top) */
.freeze-toggle {
  position: fixed; right: 24px; bottom: 72px; z-index: 9999;
  height: 32px; padding: 0 12px;
  font: 700 11px/1 'Nunito', sans-serif; color: #7030a0;
  background: rgba(255,255,255,0.7);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.8); border-radius: 16px;
  box-shadow: 0 2px 10px rgba(120,60,180,0.2);
  cursor: pointer;
  transition: background-color .2s ease;
}
.freeze-toggle:hover { background: rgba(255,255,255,0.95); }
.freeze-toggle:focus-visible { outline: 2px dashed #b060d0; outline-offset: 2px; }
.frozen *, .frozen *::before, .frozen *::after { animation-play-state: paused !important; }
.frozen .sparkle-bit { display: none; }

/* Keyboard focus is always visible */
a:focus-visible { outline: 2px dashed #b060d0; outline-offset: 2px; border-radius: 4px; }


/* ============================================================
   BLINKIE GRID
   ============================================================ */
.blinkie-row { display: grid; grid-template-columns: repeat(3,1fr); gap: 16px; }
.blinkie-row + .blinkie-row { margin-top: 40px; }
.blinkie-col  { display: flex; flex-direction: column; gap: 4px; align-items: center; }
.blinkie-col a { display: block; text-align: center; }
.blinkie-col img { max-width: 100%; height: auto; }
.col-title {
  display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: 1px;
  color: #fff; padding: 2px 8px; border-radius: 8px; margin-bottom: 4px;
  text-shadow: 1px 1px 0 rgba(0,0,0,0.3);
}
.tag-pink   { background: #ff8fab; }
.tag-yellow { background: #f9b931; }
.tag-mint   { background: #52c192; }
.tag-blue   { background: #5ab4d6; }
.tag-purple { background: #a78bfa; }
.tag-peach  { background: #ff9a76; }


/* ============================================================
   KAO ANI PAGE
   ============================================================ */
.kao-body-text {
  font-size: 14px; line-height: 1.8; text-align: left;
  max-width: 70ch; margin: 0 auto 12px auto; color: #333;
}
.refs-list { list-style: none; padding: 0; text-align: left; max-width: 70ch; margin: 0 auto; }
.refs-list li { font-size: 13px; padding: 6px 0 6px 20px; position: relative; border-bottom: 1px dashed #eee; }
.refs-list li::before { content: "★"; position: absolute; left: 0; font-size: 14px; }
.refs-list li:nth-child(6n+1)::before { color: #ff8fab }
.refs-list li:nth-child(6n+2)::before { color: #ffd166 }
.refs-list li:nth-child(6n+3)::before { color: #caffbf }
.refs-list li:nth-child(6n+4)::before { color: #9bf6ff }
.refs-list li:nth-child(6n+5)::before { color: #bdb2ff }
.refs-list li:nth-child(6n+6)::before { color: #ffc6ff }
.refs-list a { color: #4a6cf7; font-weight: 600; }
.refs-list .ref-note { display: block; font-size: 11px; color: #888; margin-top: 2px; }


/* ============================================================
   INDEX PAGE — welcome & guestbook
   ============================================================ */
.welcome-title { font-family: 'Pacifico',cursive; font-size: 20px; color: #b060d0; margin-bottom: 12px; }
.welcome-text  { font-size: 14px; line-height: 1.8; color: #5a2a80; }
.welcome-text a { color: #c060e0; }
.imood-block { margin-top: 12px; font-size: 12px; color: #7a40a0; }
.imood-block a { color: #9060c0; text-decoration: none; }
.imood-block a:hover { text-decoration: underline; }
.imood-img { image-rendering: pixelated; vertical-align: middle; margin-left: 4px; }
.guestbook-icon { font-size: 28px; margin-bottom: 8px; }
.guestbook-frame { display: block; border-radius: 8px; }

.guestbook-title { font-family: 'Pacifico',cursive; font-size: 17px; color: #b060d0; margin-bottom: 14px; }
.guestbook-inner { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.guestbook-left {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: rgba(255,200,240,0.2); border-radius: 14px; padding: 22px 12px;
  border: 1px dashed rgba(200,130,230,0.38); text-align: center;
}
.leave-msg { font-family: 'Pacifico',cursive; font-size: 16px; color: #c060d0; line-height: 1.5; margin-bottom: 6px; }
.guestbook-left .sub { font-size: 11px; color: #a080b0; }
.guestbook-right {
  background: rgba(255,200,240,0.15); border-radius: 14px; padding: 12px;
  border: 1px solid rgba(200,160,230,0.25);
  display: flex; flex-direction: column; gap: 8px;
}
.goodday-stamp { text-align: center; padding-top: 16px; }
.goodday-stamp img { image-rendering: pixelated; max-height: 40px; }

/* People page */
.page-header-img img { max-width: 100%; image-rendering: pixelated; margin: 8px 0; }


/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 700px) {
  .body-layout { flex-direction: column; }
  .sidebar { width: 100%; position: static; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
  .sidebar-card:first-child { grid-column: 1 / -1; }
  .sidebar-card:first-child ul { columns: 2; column-gap: 12px; }
  .sidebar-card li { break-inside: avoid; }
  .content-box, .page-container { padding: 16px; }
  .to-top { right: 16px; bottom: 16px; }
  .freeze-toggle { right: 16px; bottom: 64px; }
  .guestbook-inner { grid-template-columns: 1fr; }
  .blinkie-row { grid-template-columns: 1fr; }
}

/* ============================================================
   REDUCED MOTION — everything holds still for people who ask
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  #clouds, #bubbles, #blossoms { display: none; }
}

/* Dividers page */
.divider-link { display: block; }
.divider-link img { image-rendering: pixelated; margin: 4px auto; }

/* Short intro line under a page title */
.page-intro { font-size: 14px; margin: 0 auto 16px; max-width: 60ch; }

/* Blinkies how-to */
.howto { text-align: left; max-width: 70ch; margin: 0 auto; font-size: 14px; line-height: 1.7; }
.howto ol { margin: 12px 0 16px 24px; }
.howto li { margin-bottom: 4px; }
.howto-shot { display: block; text-align: center; color: #7030a0; font-size: 13px; }
.howto-shot img { width: 240px; max-height: 360px; object-fit: cover; object-position: top; border-radius: 8px; border: 1px solid rgba(255,255,255,0.8); display: block; margin: 0 auto 8px; }
.howto-credit { font-size: 12px; color: #9060b0; margin-top: 12px; text-align: center; }

/* Link-back button (home page) */
.linkback { display: flex; flex-direction: column; align-items: center; gap: 8px; font-size: 13px; color: #7a40a0; }
.linkback-btn { image-rendering: pixelated; width: 176px; height: 62px; }
.linkback-code { width: 100%; max-width: 440px; font: 12px/1.5 ui-monospace, Menlo, Consolas, monospace; color: #4a2060; background: rgba(255,255,255,0.6); border: 1px solid rgba(200,160,230,0.5); border-radius: 8px; padding: 8px; resize: none; }
.linkback-copy { font: 700 12px 'Nunito', sans-serif; color: #fff; background: #b060d0; border: 0; border-radius: 16px; padding: 6px 16px; cursor: pointer; transition: background-color .2s ease; }
.linkback-copy:hover { background: #9040c0; }
