/* ReturnMate — traditional Japanese colors (nipponcolors.com) on Apple-style
   materials: translucent chrome, press-down feedback, size-specific tracking,
   system light/dark. Every hex below is a named nipponcolors value. */

:root {
  color-scheme: light dark;
  --bg: #FCFAF2;          /* SHIRONERI 白練 */
  --surface: #FFFFFB;     /* GOFUN 胡粉 */
  --ink: #1C1C1C;         /* SUMI 墨 */
  --muted: #656765;       /* NIBI 鈍 */
  --line: rgba(28, 28, 28, 0.12);
  --well: rgba(28, 28, 28, 0.045);
  --brand: #00896C;       /* AOTAKE 青竹 — accents, focus, selection */
  --brand-deep: #005243;  /* TETSU 鉄 — primary buttons, links */
  --brand-tint: rgba(0, 137, 108, 0.12);
  --on-brand: #FFFFFB;
  --danger: #9E3D3F;      /* ENJI 臙脂 */
  --warn: 255, 177, 27;   /* YAMABUKI 山吹 (rgb triplet for tints) */
  --chrome: rgba(252, 250, 242, 0.72);
  --input-line: rgba(28, 28, 28, 0.45);
  --shadow: 0 8px 24px rgba(28, 28, 28, 0.1);
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0C0C0C;        /* RO 呂 */
    --surface: #1C1C1C;   /* SUMI 墨 */
    --ink: #FCFAF2;       /* SHIRONERI 白練 */
    --muted: #91989F;     /* GINNEZUMI 銀鼠 */
    --line: rgba(252, 250, 242, 0.14);
    --well: rgba(252, 250, 242, 0.06);
    --brand-deep: #5DAC81; /* WAKATAKE 若竹 — the accent brightens on dark */
    --brand-tint: rgba(93, 172, 129, 0.16);
    --on-brand: #0C0C0C;
    --danger: #F17C67;    /* SANGOSHU 珊瑚朱 */
    --chrome: rgba(12, 12, 12, 0.8);
    --input-line: rgba(252, 250, 242, 0.5);
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 100%/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}

::selection { background: var(--brand-deep); color: var(--on-brand); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
#app:focus { outline: none; }

main a { color: var(--brand-deep); }
/* tap-highlight is suppressed globally, so every tappable needs its own press state */
main a:active, nav a:active, .logo:active, .crumb:active { opacity: 0.5; }

/* ---------- chrome: translucent, content scrolls under, edge appears on scroll ---------- */

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.875rem 1.25rem;
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--chrome);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
  box-shadow: 0 1px 0 transparent;
  transition: box-shadow 0.3s ease;
}
header.scrolled { box-shadow: 0 1px 0 var(--line), 0 4px 16px rgba(28, 28, 28, 0.06); }

.logo { font-weight: 700; font-size: 1.125rem; letter-spacing: -0.01em; text-decoration: none; color: var(--ink); white-space: nowrap; }
nav a { margin-left: 1rem; text-decoration: none; color: var(--muted); font-weight: 500; white-space: nowrap; transition: color 0.15s ease; }
nav a:hover { color: var(--ink); }

main { max-width: 45rem; margin: 0 auto; padding: 1.5rem 1.25rem 3.75rem; }
footer { text-align: center; color: var(--muted); font-size: 0.8125rem; letter-spacing: 0.01em; padding: 1.25rem; }

/* ---------- type: tracking tightens as size grows ---------- */

h1 {
  font-size: clamp(1.75rem, 3.5vw, 2.25rem);
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-weight: 700;
  margin: 0.625rem 0 0.375rem;
}
h2 { font-size: 1.1875rem; line-height: 1.25; letter-spacing: -0.01em; margin: 0 0 0.625rem; }
.muted { color: var(--muted); }
.small { font-size: 0.8125rem; letter-spacing: 0.01em; }

/* ---------- pages arrive with a soft rise (cross-fade under reduced motion) ---------- */

#app > * { animation: enter 0.45s cubic-bezier(0.16, 1, 0.3, 1) both; }
#app > *:nth-child(2) { animation-delay: 0.04s; }
#app > *:nth-child(n + 3) { animation-delay: 0.08s; }
#app.still > * { animation: none; } /* in-place updates must not replay the entrance */
@keyframes enter { from { opacity: 0; transform: translateY(8px); } }
@keyframes fade { from { opacity: 0; } }

/* ---------- surfaces ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin: 0.875rem 0;
  box-shadow: 0 1px 2px rgba(28, 28, 28, 0.04);
}

/* ---------- buttons: instant press-down, pill-shaped ---------- */

.btn {
  display: inline-block;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 999px;
  padding: 0.625rem 1.125rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition:
    transform 0.15s cubic-bezier(0.2, 0.9, 0.3, 1),
    background-color 0.2s ease, border-color 0.2s ease, filter 0.2s ease;
}
.btn:hover { background: var(--well); }
.btn:active { transform: scale(0.97); transition-duration: 0.06s; }
.btn.primary { background: var(--brand-deep); border-color: transparent; color: var(--on-brand); }
.btn.primary:hover { filter: brightness(1.1); background: var(--brand-deep); }
.btn.primary:disabled { opacity: 0.45; cursor: not-allowed; transform: none; filter: none; }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--well); }
.btn.small { padding: 0.375rem 0.75rem; font-size: 0.8125rem; letter-spacing: 0.01em; }
[data-reset] { color: var(--danger); }

.crumb { color: var(--muted); text-decoration: none; font-size: 0.875rem; transition: color 0.15s ease; }
.crumb:hover { color: var(--ink); }

/* ---------- home ---------- */

.hero {
  text-align: center;
  padding: 3rem 1.5rem;
  background: linear-gradient(180deg, var(--brand-tint), transparent 70%) var(--surface);
}
.hero h1 { font-size: clamp(2rem, 5vw, 2.75rem); letter-spacing: -0.022em; }
.hero p { max-width: 30rem; margin: 0.625rem auto 1.125rem; }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(11.875rem, 1fr)); gap: 0.875rem; }
.grid .card { margin: 0; }

/* ---------- store picker: cards lift toward the pointer, press down on tap ---------- */

.store-card {
  display: block;
  text-decoration: none;
  color: inherit;
  border-top: 4px solid var(--accent, var(--brand));
  transition: transform 0.25s cubic-bezier(0.2, 0.9, 0.3, 1), box-shadow 0.25s ease;
}
.store-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.store-card:active { transform: scale(0.98); transition-duration: 0.06s; }
.store-icon { font-size: 1.875rem; }
.policy { font-size: 0.8125rem; letter-spacing: 0.01em; color: var(--muted); margin-bottom: 0; }

.store-chip {
  display: inline-block;
  font-weight: 700;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent, var(--brand));
  margin-top: 0.75rem;
}

/* ---------- stepper ---------- */

.stepper {
  display: flex;
  gap: 0.5rem;
  list-style: none;
  padding: 0;
  margin: 1rem 0 0.25rem;
  font-size: 0.8125rem;
  letter-spacing: 0.01em;
}
.stepper li {
  flex: 1;
  min-width: 0;
  text-align: center;
  padding: 0.4375rem 0.25rem;
  border-radius: 999px;
  border: 1px solid transparent;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background-color 0.25s ease, color 0.25s ease;
}
.stepper li.current { background: var(--brand-tint); color: var(--brand-deep); font-weight: 700; }
.stepper li.done { background: var(--well); color: var(--ink); }

.notice {
  background: rgba(var(--warn), 0.14);
  border: 1px solid rgba(var(--warn), 0.5);
  padding: 0.75rem 0.875rem;
  border-radius: 12px;
  margin: 0.75rem 0;
  font-size: 0.9375rem;
}

/* ---------- forms ---------- */

.form label { display: block; margin: 0.875rem 0; font-weight: 600; }
.form input[type="text"],
.form input[type="email"],
.form textarea {
  width: 100%;
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--input-line);
  border-radius: 10px;
  font: inherit;
  font-weight: 400;
  margin-top: 0.375rem;
  background: var(--bg);
  color: var(--ink);
}
.form input:focus, .form textarea:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--brand); width: 17px; height: 17px; }

.form .item {
  display: flex;
  gap: 0.625rem;
  align-items: center;
  padding: 0.6875rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  margin: 0.5rem 0;
  font-weight: 500;
  cursor: pointer;
  transition:
    transform 0.15s cubic-bezier(0.2, 0.9, 0.3, 1),
    border-color 0.2s ease, background-color 0.2s ease;
}
.form .item:active { transform: scale(0.99); transition-duration: 0.06s; }
.form .item:has(input:checked) { border-color: var(--brand); background: var(--brand-tint); }
.form .item .right { margin-left: auto; text-align: right; }
.form .item.disabled { opacity: 0.55; cursor: not-allowed; }
.form .item.disabled:active { transform: none; }

.demo-hint { margin-top: 1rem; padding-top: 0.75rem; border-top: 1px dashed var(--line); font-size: 0.875rem; }
.demo-hint .btn { margin: 0.25rem 0.25rem 0 0; }

.row { display: flex; flex-wrap: wrap; gap: 0.625rem; justify-content: space-between; margin-top: 1.125rem; }

.summary { display: grid; grid-template-columns: 8.125rem 1fr; gap: 0.5rem 0.875rem; margin: 0; }
.summary dt { color: var(--muted); }
.summary dd { margin: 0; }

/* ---------- status ---------- */

.badge {
  display: inline-block;
  font-size: 0.75rem;
  letter-spacing: 0.02em;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
}
.badge.label_ready { background: var(--brand-tint); color: var(--brand-deep); }
.badge.dropped_off { background: var(--well); color: var(--muted); }
.badge.in_transit { background: rgba(var(--warn), 0.22); color: var(--ink); }
.badge.delivered { background: var(--brand-tint); color: var(--brand-deep); }
.badge.refunded { background: var(--brand-deep); color: var(--on-brand); }
.badge.warn { background: rgba(var(--warn), 0.22); color: var(--ink); }

.return-card { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.return-actions { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }

/* ---------- tracking timeline (simulated carrier scans) ---------- */

.timeline {
  list-style: none;
  width: 100%;
  margin: 0.25rem 0 0;
  padding: 0.5rem 0 0;
  border-top: 1px dashed var(--line);
  font-size: 0.875rem;
}
.timeline li { position: relative; padding: 0.1875rem 0 0.1875rem 1.25rem; }
.timeline li::before {
  content: "";
  position: absolute;
  left: 0.25rem;
  top: 0.55em;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--brand-deep);
}
.timeline li:not(.done) { color: var(--muted); }
.timeline li:not(.done)::before {
  background: transparent;
  border: 1.5px solid var(--muted);
  box-sizing: border-box;
}

/* ---------- label ---------- */

.label-wrap { display: flex; justify-content: center; background: var(--well); padding: 1.5rem; }
.label-wrap svg { width: 100%; max-width: 21.25rem; height: auto; box-shadow: var(--shadow); }

.empty { text-align: center; color: var(--muted); padding: 2.125rem 1.25rem; }

/* ---------- narrow screens: chrome and stepper stay one line ---------- */

@media (max-width: 26rem) {
  header { padding: 0.75rem 1rem; }
  .logo { font-size: 1rem; }
  nav a { font-size: 0.875rem; margin-left: 0.75rem; }
  .stepper { font-size: 0.75rem; gap: 0.375rem; }
  .stepper li { padding: 0.375rem 0.125rem; }
}

/* store accents are tuned for light paper; lift them on dark ink
   (browsers without color-mix keep the base accent — acceptable) */
@media (prefers-color-scheme: dark) {
  .store-card { border-top-color: color-mix(in srgb, var(--accent, var(--brand)) 65%, #FCFAF2); }
  .store-chip { border-left-color: color-mix(in srgb, var(--accent, var(--brand)) 65%, #FCFAF2); }
}

/* ---------- accessibility: gentler, frostier, sharper on request ---------- */

@media (prefers-reduced-motion: reduce) {
  #app > * { animation: fade 0.2s ease both; }
  .store-card:hover { transform: none; }
  .btn, .store-card, .form .item, .stepper li, header { transition: none; }
}

@media (prefers-reduced-transparency: reduce) {
  header { background: var(--bg); -webkit-backdrop-filter: none; backdrop-filter: none; }
}

@media (prefers-contrast: more) {
  :root { --line: rgba(28, 28, 28, 0.55); }
  header { background: var(--bg); -webkit-backdrop-filter: none; backdrop-filter: none; }
  .card, .btn { border-color: var(--line); }
}
@media (prefers-contrast: more) and (prefers-color-scheme: dark) {
  :root { --line: rgba(252, 250, 242, 0.6); }
}
