/* KRS Payals: dark mode and page motion.
   Dark mode follows the phone's setting unless the visitor picks one with the moon/sun button
   (a tiny script at the top of index.html sets data-theme before the page draws).
   Motion: only opacity, transform and clip-path move, with strong ease-out curves.
   The page's own "reduce motion" rule makes every animation instant. */

:root {
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
}

/* ---------- Dark mode ---------- */

:root[data-theme="dark"] {
  --silver-pale: #16191B; /* text on the light buttons */
  --silver-mid: #3A4249;
  --oxide: #E4E6E1;       /* main text */
  --oxide-soft: #A7ADA8;
  --kumkum: #E3909B;
  --brass: #D4B25A;
  --paper: #111416;
  --card: #191D20;
  --rule: 1px solid rgba(228, 230, 225, .14);
  color-scheme: dark;
}
[data-theme="dark"] .sound { border-color: rgba(228, 230, 225, .25); }
[data-theme="dark"] .btn.ghost { border-color: rgba(228, 230, 225, .3); }
[data-theme="dark"] .group li { border-bottom-color: rgba(228, 230, 225, .16); }
[data-theme="dark"] .stage svg > path { stroke: #A7ADA8; }   /* the hook */
[data-theme="dark"] .stage svg > circle { fill: #A7ADA8; }
[data-theme="dark"] .cat-chip,
[data-theme="dark"] .size-chip,
[data-theme="dark"] .cat-sheet .nav button { border-color: rgba(228, 230, 225, .25); }
[data-theme="dark"] .cat-sample-note { background: rgba(227, 144, 155, .08); }
[data-theme="dark"] .cat-sheet .grab { background: rgba(228, 230, 225, .25); }

/* The moon/sun button, top right of the page */
.wrap { position: relative; }
.theme-btn {
  position: absolute;
  z-index: 2; /* above the brand name, whose entrance animation puts it on its own layer */
  top: 1.45rem;
  right: 1.1rem;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(29, 34, 38, .22);
  border-radius: 50%;
  background: none;
  color: var(--oxide);
  transition: transform 160ms var(--ease-out);
}
[data-theme="dark"] .theme-btn { border-color: rgba(228, 230, 225, .25); }
.theme-btn:active { transform: scale(.97); }
.theme-btn svg { width: 19px; height: 19px; }
.theme-btn .sun { display: none; }
[data-theme="dark"] .theme-btn .sun { display: block; }
[data-theme="dark"] .theme-btn .moon { display: none; }

/* The ⚙ Settings button sits left of the moon/sun button */
.settings-btn {
  position: absolute;
  z-index: 2;
  top: 1.45rem;
  left: 1.1rem;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(29, 34, 38, .22);
  border-radius: 50%;
  background: none;
  color: var(--oxide);
  transition: transform 160ms var(--ease-out);
}
[data-theme="dark"] .settings-btn { border-color: rgba(228, 230, 225, .25); }
.settings-btn:active { transform: scale(.97); }
.settings-btn svg { width: 19px; height: 19px; }

/* Switching theme: the new colours spread out in a circle (motion.js).
   Switching look: a soft cross-fade. */
::view-transition-old(root),
::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
.vt-fade::view-transition-old(root),
.vt-fade::view-transition-new(root) { animation: revert; animation-duration: 300ms; }

/* ⚙ Settings sheet */
dialog.settings-sheet {
  position: fixed;
  inset: auto 0 0 0;
  margin: 0 auto;
  width: 100%;
  max-width: 560px;
  padding: 0 0 env(safe-area-inset-bottom);
  border: 0;
  border-radius: 14px 14px 0 0;
  background: var(--paper);
  color: var(--oxide);
  max-height: calc(100dvh - 1rem); /* six looks: scrolls on small phones */
  overflow-y: auto;
  overscroll-behavior: contain;
  transform: translateY(100%);
  transition: transform 250ms cubic-bezier(0.32, 0.72, 0, 1), overlay 250ms allow-discrete, display 250ms allow-discrete;
}
dialog.settings-sheet[open] { transform: translateY(0); }
@starting-style { dialog.settings-sheet[open] { transform: translateY(100%); } }
dialog.settings-sheet::backdrop { background: rgb(0 0 0 / .45); }
.settings-sheet .grab { width: 40px; height: 4px; border-radius: 2px; background: rgba(29, 34, 38, .2); margin: .6rem auto 0; }
[data-theme="dark"] .settings-sheet .grab { background: rgba(228, 230, 225, .25); }
.settings-inner { padding: .6rem 1.5rem 1.4rem; display: flex; flex-direction: column; gap: .7rem; }
.settings-inner h2 { font-size: 1.35rem; margin: 0; }
.settings-label { margin: .3rem 0 0; font-size: .8rem; color: var(--oxide-soft); }
.settings-hint { margin: 0; font-size: .8rem; color: var(--oxide-soft); }
.look-choices { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.look-choices button {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: .2rem;
  padding: .55rem .55rem .7rem;
  border: 1.5px solid rgba(29, 34, 38, .2);
  border-radius: 10px;
  background: none;
  color: var(--oxide);
  text-align: left;
  transition: transform 160ms var(--ease-out), border-color 150ms ease;
}
[data-theme="dark"] .look-choices button { border-color: rgba(228, 230, 225, .22); }
.look-choices button:active { transform: scale(.97); }
.look-choices button[aria-checked="true"] { border-color: var(--brass); box-shadow: 0 0 0 1px var(--brass); }
.swatch { display: block; width: 100%; aspect-ratio: 2 / 1; border-radius: 6px; margin-bottom: .35rem; box-shadow: inset 0 0 0 1px rgba(128, 128, 128, .3); }
.swatch.classic { background: linear-gradient(135deg, #F0F1ED 0 50%, #1D2226 50% 100%); box-shadow: inset 0 0 0 1px rgba(29, 34, 38, .15); }
.swatch.showroom { background: radial-gradient(70% 90% at 50% 0%, rgba(190, 215, 255, .4), transparent 70%), linear-gradient(135deg, #1B2A45, #0E1626); box-shadow: inset 0 0 0 2px #C3CBD6; }
.look-name { font-weight: 500; font-size: .95rem; }
.look-note { font-size: .76rem; color: var(--oxide-soft); }
.look-by { margin-top: .15rem; font-size: .66rem; letter-spacing: .05em; text-transform: uppercase; color: var(--oxide-soft); }
.mode-choices { display: grid; grid-template-columns: repeat(3, 1fr); gap: .4rem; }
.mode-choices button {
  min-height: 42px;
  border: 1px solid rgba(29, 34, 38, .25);
  border-radius: 8px;
  background: none;
  color: var(--oxide);
  font-size: .9rem;
  transition: transform 160ms var(--ease-out), background-color 150ms ease, color 150ms ease;
}
[data-theme="dark"] .mode-choices button { border-color: rgba(228, 230, 225, .25); }
.mode-choices button:active { transform: scale(.97); }
.mode-choices button[aria-checked="true"] { background: var(--oxide); color: var(--silver-pale); border-color: var(--oxide); }
.settings-inner .btn { margin-top: .4rem; }

/* ---------- When the page opens: everything rises in, one after another ---------- */

@keyframes krs-rise {
  from { opacity: 0; transform: translateY(14px); }
}
.motion .mark,
.motion .hero .stage,
.motion .hero .hint,
.motion .hero h1,
.motion .hero .sub,
.motion .hero .actions .btn {
  animation: krs-rise 600ms var(--ease-out) both;
}
.motion .hero .stage { animation-delay: 80ms; }
.motion .hero .hint { animation-delay: 160ms; }
.motion .hero h1 { animation-delay: 220ms; }
.motion .hero .sub { animation-delay: 300ms; }
.motion .hero .actions .btn:nth-child(1) { animation-delay: 380ms; }
.motion .hero .actions .btn:nth-child(2) { animation-delay: 440ms; }
.motion .hero .actions .btn:nth-child(3) { animation-delay: 500ms; }

/* ---------- Scrolling: a silver chain draws itself across, then the section appears ---------- */
/* Only for sections below the screen when the page opens, and only once. */

.band.has-chain { border-top: 0; padding-top: 0; }
.chain-rule { display: block; width: 100%; height: 10px; margin: 0 0 1.5rem; color: var(--oxide-soft); }
.chain-rule.armed { clip-path: inset(0 100% 0 0); }
.chain-rule.armed.shown { clip-path: inset(0 0 0 0); transition: clip-path 900ms var(--ease-in-out); }

@media (prefers-reduced-motion: reduce) {
  .motion .mark, .motion .hero * { animation-delay: 0ms !important; }
}

.band-body.armed { opacity: 0; transform: translateY(16px); }
.band-body.armed.shown {
  opacity: 1;
  transform: none;
  transition: opacity 600ms var(--ease-out) 250ms, transform 600ms var(--ease-out) 250ms;
}

/* ---------- Opening the catalogue page: its heading and range buttons rise in ---------- */
.motion.page-cat #catalogue .cat-back,
.motion.page-cat #catalogue h2,
.motion.page-cat #catalogue .cat-note,
.motion.page-cat #catalogue .cat-chips { animation: krs-rise 500ms var(--ease-out) both; }
.motion.page-cat #catalogue h2 { animation-delay: 60ms; }
.motion.page-cat #catalogue .cat-note { animation-delay: 120ms; }
.motion.page-cat #catalogue .cat-chips { animation-delay: 180ms; }

/* ---------- App-style looks (Kolam, Kolam White, Boutique) are drawn by a script ----------
   Until the script has run (slow connection), show a soft pulsing mark instead of an empty screen. */
:is([data-look^="kolam"], [data-look="boutique"]):not(.admin) body:not(:has(#kolam-app, #boutique-app))::before {
  content: "KRS";
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  font: 600 .95rem/1 system-ui, sans-serif;
  letter-spacing: .35em;
  color: var(--oxide-soft);
  animation: krs-wait 1.1s ease-in-out infinite alternate;
}
@keyframes krs-wait { from { opacity: .2; } to { opacity: .75; } }

/* ---------- ⚙ Settings: looks in folders (Store, App, First looks) ---------- */
.look-folders { display: flex; flex-direction: column; gap: .5rem; }
.look-folder { border: 1px solid rgba(29, 34, 38, .16); border-radius: 12px; }
[data-theme="dark"] .look-folder { border-color: rgba(228, 230, 225, .18); }
.look-folder > summary {
  display: flex;
  align-items: center;
  gap: .6rem;
  min-height: 52px;
  padding: .45rem .75rem;
  list-style: none;
  cursor: pointer;
  border-radius: 12px;
}
.look-folder > summary::-webkit-details-marker { display: none; }
.look-folder > summary:focus-visible { outline: 2.5px solid var(--kumkum); outline-offset: 2px; }
.look-folder .chev { width: 18px; height: 18px; flex: none; color: var(--oxide-soft); transition: transform 200ms var(--ease-out); }
.look-folder[open] .chev { transform: rotate(90deg); }
.folder-text { display: flex; flex-direction: column; min-width: 0; }
.folder-name { font-weight: 500; font-size: .95rem; }
.folder-count { font-size: .76rem; font-weight: 400; color: var(--oxide-soft); margin-left: .2rem; }
.folder-note { font-size: .76rem; color: var(--oxide-soft); }
.folder-peek { margin-left: auto; display: flex; flex: none; padding-left: 6px; }
.folder-peek .swatch.peek {
  width: 22px;
  height: 22px;
  aspect-ratio: auto;
  margin: 0 0 0 -6px;
  border-radius: 50%;
  box-shadow: 0 0 0 2px var(--paper), inset 0 0 0 1px rgba(128, 128, 128, .35);
}
.look-folder .look-choices { padding: 0 .6rem .7rem; }
@media (prefers-reduced-motion: reduce) { .look-folder .chev { transition: none; } }
