/* ============================================================
   showa.day — bento-box · honeyed-neutral · border-animate
   ============================================================
   Palette:
     #F5EBD8 honeyed cream    (primary background)
     #FBF6EC soft pearl       (elevated cell)
     #2A211A deep umber       (text)
     #C8923E lacquer amber    (borders, accents)
     #F2C661 honey glow       (lens-flare, prism highlight)
     #B8C9D6 prism pale-blue  (cool refraction)
   Fonts: Fraunces · Inter Tight · Klee One
   ============================================================ */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --cream: #F5EBD8;
  --pearl: #FBF6EC;
  --umber: #2A211A;
  --amber: #C8923E;
  --honey: #F2C661;
  --prism: #B8C9D6;

  --cell-radius: 4px;
  --gap: 16px;
  --pad: 32px;
  --border-w: 1px;

  --font-display: "Fraunces", serif;
  --font-body: "Inter Tight", system-ui, sans-serif;
  --font-jp: "Klee One", serif;
}

html,
body {
  background: var(--cream);
  color: var(--umber);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  position: relative;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ----------------------------- Washi grain ---------------------------- */
.washi-grain {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
  mix-blend-mode: multiply;
  opacity: 1;
}

/* ----------------------------- Bento page ----------------------------- */
.bento-page {
  position: relative;
  z-index: 2;
  padding: var(--pad);
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.tray {
  position: relative;
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  grid-auto-rows: minmax(80px, auto);
  gap: var(--gap);
  isolation: isolate;
}

.tray-1 { grid-template-rows: repeat(6, minmax(80px, auto)); min-height: calc(100vh - var(--pad) * 2); }
.tray-2 { grid-template-rows: repeat(4, minmax(96px, auto)); }
.tray-3 { grid-template-rows: repeat(4, minmax(88px, auto)); }
.tray-4 { grid-template-rows: repeat(2, minmax(120px, auto)); }

/* ----------------------------- Lens flares ---------------------------- */
.flare {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  mix-blend-mode: screen;
}

.flare-a {
  background:
    radial-gradient(circle at 70% 30%,
      rgba(242, 198, 97, 0.45) 0%,
      rgba(242, 198, 97, 0.18) 8%,
      transparent 22%);
  animation: flare-drift 24s ease-in-out infinite;
}

.flare-b {
  background:
    radial-gradient(circle at 30% 65%,
      rgba(242, 198, 97, 0.22) 0%,
      rgba(242, 198, 97, 0.08) 6%,
      transparent 16%);
  animation: flare-drift-b 28s ease-in-out infinite reverse;
}

@keyframes flare-drift {
  0%   { transform: translate(0, 0); }
  50%  { transform: translate(40px, 22px); }
  100% { transform: translate(0, 0); }
}

@keyframes flare-drift-b {
  0%   { transform: translate(0, 0); }
  50%  { transform: translate(-30px, -18px); }
  100% { transform: translate(0, 0); }
}

/* ----------------------------- Cells ---------------------------------- */
.cell {
  position: relative;
  grid-column: var(--col);
  grid-row: var(--row);
  background: var(--cream);
  border-radius: var(--cell-radius);
  padding: 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  justify-content: flex-start;
  z-index: 1;
  transition: background 600ms ease;
  overflow: hidden;
}

.cell.cell-pearl,
.cell:nth-of-type(7n+3) {
  background: var(--pearl);
}

.cell-empty {
  background: transparent;
  pointer-events: none;
}

/* animated hairline border via 4 absolutely-positioned segments */
.cell::before,
.cell::after,
.cell .border-top,
.cell .border-bottom {
  /* placeholder selectors removed — borders done with two pseudo elements */
}

.cell:not(.cell-empty)::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: var(--cell-radius);
  pointer-events: none;
  box-shadow:
    inset 0 var(--border-w) 0 0 var(--amber),
    inset 0 0 0 0 var(--amber);
  clip-path: inset(0 100% 100% 0);
  animation: none;
  z-index: 3;
}

.cell:not(.cell-empty)::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: var(--cell-radius);
  pointer-events: none;
  box-shadow:
    inset 0 0 0 var(--border-w) var(--amber),
    inset 0 0 0 0 rgba(242, 198, 97, 0);
  opacity: 0;
  transition: box-shadow 220ms ease, opacity 700ms ease;
  z-index: 4;
}

/* when revealed, ::before completes its full inset frame, then ::after holds it */
.cell.revealed:not(.cell-empty)::before {
  animation: border-draw 1.4s ease forwards;
}
.cell.revealed:not(.cell-empty)::after {
  animation: border-glow 700ms ease 1.4s forwards;
}

@keyframes border-draw {
  0%   { clip-path: inset(0 100% 100% 0); box-shadow: inset 0 var(--border-w) 0 0 var(--amber); }
  25%  { clip-path: inset(0 0 100% 0);   box-shadow: inset 0 var(--border-w) 0 0 var(--amber); }
  50%  { clip-path: inset(0 0 100% 0);   box-shadow: inset 0 0 0 var(--border-w) var(--amber); }
  75%  { clip-path: inset(0 0 0 0);      box-shadow: inset 0 0 0 var(--border-w) var(--amber); }
  100% { clip-path: inset(0 0 0 0);      box-shadow: inset 0 0 0 var(--border-w) var(--amber); }
}

@keyframes border-glow {
  0%   { opacity: 0; box-shadow: inset 0 0 0 var(--border-w) var(--amber), inset 0 0 0 rgba(242, 198, 97, 0); }
  40%  { opacity: 1; box-shadow: inset 0 0 0 var(--border-w) var(--amber), inset 0 0 18px rgba(242, 198, 97, 0.32); }
  100% { opacity: 1; box-shadow: inset 0 0 0 var(--border-w) var(--amber), inset 0 0 0 rgba(242, 198, 97, 0); }
}

/* hover — thicken border + intensify amber glow */
.cell.revealed:not(.cell-empty):hover::after {
  opacity: 1;
  box-shadow:
    inset 0 0 0 2px var(--amber),
    inset 0 0 22px rgba(242, 198, 97, 0.38);
}

/* ----------------------------- Cell label ----------------------------- */
.cell-label {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(42, 33, 26, 0.55);
}

/* ----------------------------- Hero glyph ----------------------------- */
.hero-glyph-wrap {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 280px;
}

.era-glyph {
  font-family: var(--font-jp);
  font-weight: 600;
  font-size: clamp(8rem, 16vw, 14rem);
  color: var(--amber);
  line-height: 1;
  letter-spacing: 0;
  position: relative;
  z-index: 2;
}

.kanji-flare {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 50% 50%,
      rgba(242, 198, 97, 0.55) 0%,
      rgba(242, 198, 97, 0.18) 14%,
      transparent 36%);
  mix-blend-mode: screen;
  z-index: 1;
  pointer-events: none;
  animation: kanji-pulse 6s ease-in-out infinite;
}

@keyframes kanji-pulse {
  0%, 100% { opacity: 0.9; transform: scale(1); }
  50%      { opacity: 1;   transform: scale(1.04); }
}

/* ----------------------------- Display title -------------------------- */
.display-title {
  font-family: var(--font-display);
  font-weight: 300;
  font-style: italic;
  font-size: clamp(2.4rem, 5.6vw, 4.8rem);
  line-height: 1.05;
  letter-spacing: -0.015em;
  color: var(--umber);
  font-variation-settings: "opsz" 144;
}

.display-sub {
  font-family: var(--font-display);
  font-weight: 400;
  font-style: italic;
  font-size: clamp(1.1rem, 1.6vw, 1.4rem);
  color: rgba(42, 33, 26, 0.7);
  font-variation-settings: "opsz" 14;
  margin-top: -4px;
}

/* ----------------------------- Hanko stamp ---------------------------- */
.hanko {
  display: inline-block;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  font-size: 0.74rem;
  letter-spacing: 0.02em;
  color: var(--amber);
  border: 2px solid var(--amber);
  padding: 4px 10px;
  margin-top: 8px;
  font-variation-settings: "opsz" 9;
  align-self: flex-start;
  background: rgba(242, 198, 97, 0.08);
}

.hanko-rotate {
  transform: rotate(-4deg);
  transform-origin: left center;
}

/* ----------------------------- Haiku ---------------------------------- */
.haiku {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 1.05rem;
  line-height: 1.75;
  color: var(--umber);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.haiku span {
  display: block;
}

.haiku span:nth-child(2) {
  padding-left: 1.4em;
  color: rgba(42, 33, 26, 0.86);
}

.haiku span:nth-child(3) {
  padding-left: 2.6em;
  font-style: italic;
  font-family: var(--font-display);
  font-variation-settings: "opsz" 24;
  color: var(--amber);
}

/* ----------------------------- Body text ------------------------------ */
.body-text {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 1.05rem;
  line-height: 1.75;
  color: var(--umber);
  max-width: 56ch;
}

.body-text + .body-text {
  margin-top: 6px;
}

/* ----------------------------- Artifact lines ------------------------- */
.artifact-line {
  font-family: var(--font-body);
  font-size: 0.98rem;
  font-weight: 400;
  color: var(--umber);
  line-height: 1.4;
}

.artifact-line .year {
  font-family: var(--font-display);
  font-weight: 400;
  font-style: italic;
  font-size: 1.3rem;
  color: var(--amber);
  font-variation-settings: "opsz" 60;
  margin-right: 6px;
}

/* ----------------------------- Today tray ----------------------------- */
.today-tag {
  font-family: var(--font-display);
  font-weight: 300;
  font-size: clamp(2.6rem, 6vw, 4rem);
  font-style: italic;
  color: var(--amber);
  line-height: 1;
  font-variation-settings: "opsz" 144;
  letter-spacing: -0.02em;
}

.coords-line {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  color: rgba(42, 33, 26, 0.7);
  text-transform: uppercase;
}

.inscription {
  font-family: var(--font-display);
  font-weight: 300;
  font-style: italic;
  font-size: clamp(2rem, 4.6vw, 3.6rem);
  line-height: 1.15;
  color: var(--umber);
  font-variation-settings: "opsz" 144;
  letter-spacing: -0.01em;
  align-self: center;
  text-align: left;
  flex: 1;
  display: flex;
  align-items: center;
}

.inscription em {
  color: var(--amber);
  font-style: italic;
}

/* ----------------------------- Kanji line ----------------------------- */
.kanji-line {
  font-family: var(--font-jp);
  font-weight: 400;
  font-size: 1.4rem;
  line-height: 1.6;
  color: var(--umber);
}

/* ----------------------------- Closing -------------------------------- */
.closing-jp {
  font-family: var(--font-jp);
  font-weight: 600;
  font-size: clamp(3rem, 7vw, 5rem);
  color: var(--amber);
  line-height: 1;
  letter-spacing: 0.08em;
  text-align: center;
}

.cell-closing {
  align-items: center;
  justify-content: center;
}

.cell-closing .hanko {
  align-self: center;
  margin-top: 18px;
}

/* ----------------------------- Prism ornaments ------------------------ */
.cell-prism {
  align-items: center;
  justify-content: center;
  padding: 14px;
}

.prism {
  width: 64px;
  height: 64px;
  filter: drop-shadow(0 4px 12px rgba(200, 146, 62, 0.22));
  animation: prism-rotate 18s linear infinite;
  transform-origin: 50% 50%;
}

.prism-tall {
  width: 88px;
  height: 88px;
}

.prism-divider {
  width: 48px;
  height: 48px;
  animation: prism-rotate 14s linear infinite;
}

.prism-closing {
  width: 140px;
  height: 140px;
  animation: prism-rotate 22s linear infinite;
}

@keyframes prism-rotate {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* ----------------------------- Dividers ------------------------------- */
.divider {
  position: relative;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

.divider::before {
  content: "";
  position: absolute;
  left: 8%;
  right: 8%;
  top: 50%;
  height: 1px;
  background:
    linear-gradient(to right,
      transparent 0%,
      rgba(200, 146, 62, 0.18) 12%,
      rgba(200, 146, 62, 0.36) 50%,
      rgba(200, 146, 62, 0.18) 88%,
      transparent 100%);
}

.divider::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 50% 50%,
      rgba(242, 198, 97, 0.22) 0%,
      transparent 40%);
  mix-blend-mode: screen;
  animation: divider-flare 12s ease-in-out infinite;
  pointer-events: none;
}

@keyframes divider-flare {
  0%   { transform: translateX(-30%); opacity: 0.6; }
  50%  { transform: translateX(30%);  opacity: 1; }
  100% { transform: translateX(-30%); opacity: 0.6; }
}

/* ----------------------------- Tray 4 closing align ------------------- */
.tray-4 .cell-prism {
  background: transparent;
}

.tray-4 .cell-prism::before,
.tray-4 .cell-prism::after {
  display: none;
}

/* ----------------------------- Responsive ----------------------------- */
@media (max-width: 720px) {
  :root {
    --pad: 18px;
    --gap: 12px;
  }

  .tray {
    grid-template-columns: 1fr;
    grid-auto-rows: minmax(80px, auto);
  }

  .cell {
    grid-column: 1 / -1 !important;
    grid-row: auto !important;
    padding: 18px;
  }

  .cell-empty {
    display: none;
  }

  .hero-glyph-wrap {
    min-height: 180px;
  }

  .display-title { font-size: clamp(2rem, 8vw, 3rem); }
  .closing-jp    { font-size: clamp(2.4rem, 12vw, 3.4rem); }

  .prism         { width: 56px; height: 56px; }
  .prism-tall    { width: 64px; height: 64px; }
  .prism-closing { width: 96px; height: 96px; }
}

/* ----------------------------- Reduced motion ------------------------- */
@media (prefers-reduced-motion: reduce) {
  .flare-a, .flare-b,
  .kanji-flare,
  .prism, .prism-tall, .prism-divider, .prism-closing,
  .divider::after {
    animation: none !important;
  }

  .cell:not(.cell-empty)::before {
    animation: none !important;
    clip-path: inset(0 0 0 0);
    box-shadow: inset 0 0 0 var(--border-w) var(--amber);
  }

  .cell:not(.cell-empty)::after {
    animation: none !important;
    opacity: 1;
    box-shadow: inset 0 0 0 var(--border-w) var(--amber);
  }
}
