/* A Day Like Any Other — styles
   Palette is fixed by the brief. Calm → grayscale → hopeful. */
/* Bundled fonts (SIL OFL): SolaimanLipi for Bengali, Ma Shan Zheng for Chinese. */
@font-face { font-family: 'SolaimanLipi'; src: url('../fonts/SolaimanLipi-Regular.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'SolaimanLipi'; src: url('../fonts/SolaimanLipi-Bold.woff2') format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Ma Shan Zheng'; src: url('../fonts/MaShanZheng-subset.woff2') format('woff2'); font-weight: 400 700; font-display: swap; }

:root {
  --bg: #F5F3EE;
  --bg-warm: #ECE9E2;
  --sage: #8A9A7B;
  --sage-hi: #A8B89A;
  --ash: #B0B0B0;
  --sky: #A3C1D9;
  --ink: #555555;
  --ink-soft: #8C8C8C;
  --ground: #E4E0D7;
  --forest: #3F5A46;
  --slate: #4E6378;
  /* System fonts only: Latin first, then Bengali and Chinese faces the OS already has. */
  --font: 'Helvetica Neue', Helvetica, Arial, 'Noto Sans Bengali', 'Nirmala UI', 'Kohinoor Bangla', 'Vrinda', 'PingFang SC', 'Microsoft YaHei', 'Noto Sans SC', sans-serif;
}

html[lang="bn"] { --font: 'SolaimanLipi', 'Helvetica Neue', Arial, sans-serif; }
html[lang="zh-CN"] { --font: 'Ma Shan Zheng', 'PingFang SC', 'Microsoft YaHei', sans-serif; }
/* Ma Shan Zheng is a brush face with one weight — don't fake-bold it. */
html[lang="zh-CN"] body, html[lang="zh-CN"] #stage text { font-synthesis: none; }

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

#app {
  position: fixed;
  inset: 0;
  background: var(--bg);
  overflow: hidden;
}

#bleed {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  background:
    radial-gradient(120% 80% at 20% 0%, rgba(138, 154, 123, 0.28), transparent 60%),
    radial-gradient(120% 80% at 85% 100%, rgba(163, 193, 217, 0.32), transparent 60%),
    linear-gradient(180deg, #EDF0E8 0%, #E6EDF1 100%);
}

#stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* ---------- SVG prop language: flat outline, thick stroke ---------- */
#ground { stroke: var(--ground); stroke-width: 4; stroke-linecap: round; }

#stage text {
  font-family: var(--font);
  font-weight: 700;
  fill: var(--ink);
}

/* .p sets the outline only; fills come from attributes (or .o / .pf). */
.p {
  stroke: var(--ink);
  stroke-width: 6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.p.thin { stroke-width: 4; }
.p.hair { stroke-width: 3; }
.pf { fill: var(--bg); }
.o { fill: none; }
.hit { fill: transparent; stroke: none; }

.tap-target { cursor: pointer; }
.drag-item { cursor: grab; }
.drag-item:active { cursor: grabbing; }

.tap-target:focus, .drag-item:focus, .drop-zone:focus { outline: none; }
.tap-target:focus-visible .focus-ring,
.drag-item:focus-visible .focus-ring,
.drop-zone:focus-visible .focus-ring { opacity: 1; }
.focus-ring {
  fill: none;
  stroke: var(--sky);
  stroke-width: 4;
  stroke-dasharray: 8 8;
  opacity: 0;
  pointer-events: none;
}

/* ---------- time of day ---------- */
#sky { position: absolute; inset: 0; pointer-events: none; }
#sky .sky-layer { position: absolute; inset: 0; }

#clock {
  position: absolute;
  top: max(16px, env(safe-area-inset-top));
  left: max(16px, env(safe-area-inset-left));
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 18px 8px 10px;
  border-radius: 999px;
  background: rgba(251, 250, 247, 0.92);
  box-shadow: 0 2px 0 rgba(59, 59, 59, 0.9), 0 6px 18px rgba(40, 40, 40, 0.12);
  border: 2.5px solid #3B3B3B;
  font-weight: 700;
  font-size: clamp(20px, 3.2vmin, 28px);
  letter-spacing: 0.06em;
  color: #2E2E2E;
  opacity: 0;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}
#clock .i { width: 1.35em; height: 1.35em; display: block; }
#clock, .rv-head { font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; }
/* Chinese: keep the data numbers in a clean face, the brush digits are hard to read. */
html[lang="zh-CN"] .rv-num { font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; }
#clock .i svg { width: 100%; height: 100%; display: block; }

/* ---------- Reveal + Solutions (HTML layer, responsive) ---------- */
#reveal {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: safe center;
  overflow-y: auto; /* never lose the buttons on a small screen */
  gap: clamp(14px, 3vh, 34px);
  padding: max(20px, env(safe-area-inset-top)) 16px max(20px, env(safe-area-inset-bottom));
  color: #2B2B2B;
}
#reveal[hidden] { display: none; }

.rv-quote {
  width: min(900px, 100%);
  margin: 0 auto;
  text-align: center;
  text-wrap: balance;
  font-weight: 700;
  font-size: clamp(19px, 3.4vmin, 32px);
  line-height: 1.45;
  color: #2B2B2B;
  opacity: 0;
  pointer-events: none;
}
.rv-quote .caret {
  display: inline-block;
  width: 0.08em;
  height: 1em;
  margin-left: 0.06em;
  vertical-align: -0.12em;
  background: currentColor;
  animation: caret 0.9s steps(1) infinite;
}
@keyframes caret { 50% { opacity: 0; } }

.rv-head {
  margin: 0;
  font-weight: 700;
  font-size: clamp(18px, 3.4vmin, 30px);
  letter-spacing: 0.14em;
  opacity: 0;
}

.rv-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  width: min(1120px, 100%);
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: clamp(8px, 2vw, 28px);
}

.rv-item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  border-radius: 22px;
  padding: 6px 4px 10px;
  -webkit-appearance: none;
  outline: none;
}

.rv-art {
  position: relative;
  width: min(100%, 42vh, 260px);
  aspect-ratio: 240 / 260;
}
.rv-vig {
  display: block;
  width: min(100%, 170px);
  margin: 8px auto 0;
  aspect-ratio: 200 / 110;
  overflow: hidden; /* the car/bus drives out of its own box, never into the next column */
}
.rv-art svg { width: 100%; height: 100%; display: block; overflow: visible; }

.rv-note {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0 6%;
  font-weight: 700;
  font-size: clamp(12px, 1.6vw, 17px);
  line-height: 1.35;
  opacity: 0;
}

.rv-text {
  position: relative;
  min-height: 3.2em;
  width: 100%;
}
.rv-label, .rv-fix {
  margin: 0;
  font-size: clamp(12px, 1.45vw, 17px);
  line-height: 1.35;
  font-weight: 400;
}
.rv-label b, .rv-fix { font-weight: 700; }
.rv-label { opacity: 0; }
.rv-label .rv-val { display: block; white-space: nowrap; font-weight: 700; font-size: 1.15em; }
.rv-label .rv-task { display: block; }
.rv-plus {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.15em;
  height: 1.15em;
  margin-right: 0.2em;
  border-radius: 50%;
  background: #2B2B2B;
  color: #E9E9E7;
  font-size: 0.9em;
  font-weight: 700;
  line-height: 1;
  vertical-align: 0.05em;
}
.rv-label .rv-num { font-weight: 700; font-variant-numeric: tabular-nums; }
.rv-sub {
  display: block;
  font-size: 0.85em;
  opacity: 0.7;
  font-weight: 700;
}
.rv-fix {
  position: absolute;
  inset: 0 0 auto 0;
  opacity: 0;
  color: var(--forest);
}

.rv-end {
  margin: 0;
  font-weight: 700;
  font-size: clamp(18px, 3.2vmin, 28px);
  color: var(--forest);
  opacity: 0;
}

.rv-actions { position: relative; height: 56px; width: 56px; }
.rv-btn {
  position: absolute;
  inset: 0;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: #ECEEF2;
  box-shadow: 7px 7px 14px rgba(169, 177, 191, 0.75), -7px -7px 14px rgba(255, 255, 255, 0.95);
  transition: box-shadow 0.15s ease, transform 0.15s ease;
  color: #5E6470;
  padding: 0;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
}
.rv-btn svg { width: 100%; height: 100%; display: block; }
.rv-btn path { fill: none; stroke: currentColor; stroke-width: 3.5; stroke-linecap: round; stroke-linejoin: round; }
.rv-btn:focus-visible { outline: 3px dashed var(--sky); outline-offset: 4px; }
.rv-btn:hover { transform: translateY(-1px); }
.rv-btn:active { box-shadow: inset 5px 5px 10px rgba(169, 177, 191, 0.8), inset -5px -5px 10px rgba(255, 255, 255, 0.95); transform: none; }
.rv-replay { color: var(--forest); }

/* Solutions: fixes become pickable */
#reveal.solved .rv-item { cursor: pointer; transition: opacity 0.4s ease; }
#reveal.solved .rv-item:focus-visible { box-shadow: 0 0 0 3px var(--sky); }
#reveal.solved.has-pick .rv-item:not(.picked) { opacity: 0.38; }
#reveal.solved .rv-item {
  background: rgba(236, 238, 242, 0.85);
  box-shadow: 7px 7px 16px rgba(169, 177, 191, 0.55), -7px -7px 16px rgba(255, 255, 255, 0.9);
}
#reveal .rv-item.picked {
  background: rgba(229, 232, 237, 0.95);
  box-shadow: inset 6px 6px 12px rgba(169, 177, 191, 0.7), inset -6px -6px 12px rgba(255, 255, 255, 0.95);
}

/* The bus line lives in the art on wide screens, in the label on phones. */
.rv-busline { display: none; }

/* Narrow screens: piles become a vertical list */
@media (max-width: 700px) {
  #reveal { gap: 10px; }
  .rv-grid {
    grid-template-columns: 1fr;
    gap: 2px;
    width: min(420px, 100%);
  }
  .rv-item {
    flex-direction: row;
    align-items: flex-end; /* labels sit on the pile's ground line */
    text-align: left;
    gap: 14px;
    padding: 4px 10px;
  }
  #reveal.fixing .rv-item { align-items: center; }
  .rv-art { width: min(84px, 11vh); flex: none; }
  .rv-text { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: flex-start; min-height: 0; padding-bottom: 2px; }
  .rv-vig { width: min(100px, 12vh); margin: 2px 0 0; }
  #reveal.fixing .rv-text { justify-content: center; min-height: 2.8em; padding-bottom: 0; }
  .rv-fix { inset: 0; display: flex; align-items: center; }
  .rv-label, .rv-fix { font-size: 14px; }
  .rv-note { display: none; }
  .rv-busline { display: block; }
}

@media (max-height: 520px) and (min-width: 701px) {
  .rv-art { width: min(100%, 28vh); }
  .rv-vig { width: min(100%, 92px); margin-top: 0; }
  .rv-head { font-size: 16px; }
  .rv-quote { font-size: 17px; }
  #reveal { gap: 4px; padding-top: 10px; padding-bottom: 10px; }
  .rv-actions, .rv-btn { width: 46px; height: 46px; }
}
