/* Airsand — warm sand visual language over the production AirSend frontend.
   Every selector here is presentational; the DOM contract in app.js is untouched. */

/* ---------- fonts (self-hosted, CSP default-src 'self') ---------- */

/* latin-ext */
@font-face {
  font-family: "Caprasimo";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/static/fonts/caprasimo-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
    U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020,
    U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
  font-family: "Caprasimo";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/static/fonts/caprasimo-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}
/* latin-ext */
@font-face {
  font-family: "Figtree";
  font-style: normal;
  font-weight: 300 900;
  font-display: swap;
  src: url("/static/fonts/figtree-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
    U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020,
    U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
  font-family: "Figtree";
  font-style: normal;
  font-weight: 300 900;
  font-display: swap;
  src: url("/static/fonts/figtree-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ---------- tokens ---------- */

:root {
  --tbg: #f5ead8;          /* page — warm sand */
  --tsf: #fdf6e9;          /* card / sheet surface — cream */
  --ttx: #201e1d;          /* ink */
  --tmu: #8a7c66;          /* muted ink */
  --tbd: #e7d9bf;          /* hairline / dashed border */
  --tac: #c67139;          /* terracotta accent */
  --tac-strong: #9c5527;   /* accent, pressed / link hover */
  --tas: #f3ddc9;          /* accent soft wash */
  --ta2: #7a8a5e;          /* sage — success */
  --ta2s: #e2e6d4;         /* sage wash */
  --tok: #5c8a4e;          /* online indicator */
  --tdg: #c0392b;          /* danger */
  --tsel: #eccfae;         /* ::selection */
  --tscrim: rgba(32, 26, 16, 0.45);
  --tqr: #ffffff;          /* QR plate stays white so cameras can read it */

  --sh-card: 0 1px 3px rgba(60, 42, 20, 0.07);
  --sh-sheet: 0 -10px 44px rgba(32, 22, 8, 0.2);
  --focus-ring: rgba(198, 113, 57, 0.22);

  --r-pill: 999px;
  --r-drop: 28px;
  --r-sheet: 28px;
  --r-card: 18px;
  --r-tile: 14px;
  --r-sm: 10px;

  --dur: 200ms;
  --ease: cubic-bezier(0.25, 0.6, 0.3, 1);

  --icon-moon: block;
  --icon-sun: none;

  --font-body: "Figtree", -apple-system, BlinkMacSystemFont, "Segoe UI Variable Text",
    "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Caprasimo", Georgia, "Times New Roman", serif;
}

/* Dark palette, applied three ways so the toggle wins in both directions:
   system preference (unless the user explicitly picked light), and the
   explicit data-theme="dark" attribute set by app.js. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --tbg: #211a11;
    --tsf: #2c2417;
    --ttx: #f3e8d5;
    --tmu: #b3a389;
    --tbd: #3e3422;
    --tac: #d98c52;
    --tac-strong: #eda56d;
    --tas: #453019;
    --ta2: #98a878;
    --ta2s: #333b24;
    --tok: #8fbf7f;
    --tdg: #e8836f;
    --tsel: #5a4326;
    --tscrim: rgba(10, 7, 3, 0.62);
    --sh-card: 0 1px 3px rgba(0, 0, 0, 0.35);
    --sh-sheet: 0 -10px 44px rgba(0, 0, 0, 0.55);
    --focus-ring: rgba(217, 140, 82, 0.3);
    --icon-moon: none;
    --icon-sun: block;
  }
}

:root[data-theme="dark"] {
  --tbg: #211a11;
  --tsf: #2c2417;
  --ttx: #f3e8d5;
  --tmu: #b3a389;
  --tbd: #3e3422;
  --tac: #d98c52;
  --tac-strong: #eda56d;
  --tas: #453019;
  --ta2: #98a878;
  --ta2s: #333b24;
  --tok: #8fbf7f;
  --tdg: #e8836f;
  --tsel: #5a4326;
  --tscrim: rgba(10, 7, 3, 0.62);
  --sh-card: 0 1px 3px rgba(0, 0, 0, 0.35);
  --sh-sheet: 0 -10px 44px rgba(0, 0, 0, 0.55);
  --focus-ring: rgba(217, 140, 82, 0.3);
  --icon-moon: none;
  --icon-sun: block;
}

/* ---------- base ---------- */

* { box-sizing: border-box; }

/* app.js hides buttons via the `hidden` property; the UA rule for [hidden] is
   only display:none at low specificity, so author display rules below would
   otherwise win and leak hidden controls into the layout. */
[hidden] { display: none !important; }

html { height: 100%; }

::selection { background: var(--tsel); }

body {
  margin: 0;
  min-height: 100%;
  background: var(--tbg);
  color: var(--ttx);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
    env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.app {
  width: min(100%, 480px);
  margin: 0 auto;
  padding: 20px 20px 40px;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

@keyframes as-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes as-spin { to { transform: rotate(360deg); } }
@keyframes as-breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}
@keyframes as-sheet-up {
  from { opacity: 0; transform: translate(-50%, 24px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ---------- header ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0 26px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.brand-mark { flex: none; }

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.05;
  min-width: 0;
}

.brand-name {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 21px;
  letter-spacing: 0.2px;
}

.brand-tagline {
  font-size: 11.5px;
  color: var(--tmu);
  margin-top: 3px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
}

.iconbtn {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 1.5px solid var(--tbd);
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--ttx);
  cursor: pointer;
  transition: border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.iconbtn:hover { border-color: var(--tac); color: var(--tac); }
.iconbtn:active { transform: scale(0.94); }

.icon-moon { display: var(--icon-moon); }
.icon-sun { display: var(--icon-sun); }

/* ---------- reconnecting banner ---------- */

.banner {
  display: none;
  align-items: center;
  gap: 9px;
  margin-bottom: 16px;
  padding: 10px 16px;
  border-radius: var(--r-pill);
  background: var(--tas);
  color: var(--ttx);
  font-size: 13.5px;
  font-weight: 600;
  animation: as-in 0.25s var(--ease);
}
.banner.show { display: flex; }

/* ---------- drop zone ---------- */

.dropzone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 200px;
  padding: 28px;
  border: 2px dashed var(--tbd);
  border-radius: var(--r-drop);
  background: var(--tsf);
  box-shadow: var(--sh-card);
  cursor: pointer;
  text-align: center;
  transition: border-color var(--dur) var(--ease),
    background var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.dropzone:hover { border-color: var(--tac); }
.dropzone:active { transform: scale(0.99); }
.dropzone.dragover {
  border-color: var(--tac);
  background: var(--tas);
}

.dropzone .dz-icon {
  width: 62px;
  height: 62px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--tas);
  color: var(--tac);
  animation: as-breathe 4s ease-in-out infinite;
}

.dropzone h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 400;
  letter-spacing: 0.2px;
}

.dropzone p {
  margin: 0;
  color: var(--tmu);
  font-size: 13.5px;
}

.dz-hint-desktop { display: none; }
@media (min-width: 700px) {
  .dz-hint-mobile { display: none; }
  .dz-hint-desktop { display: block; }
}

/* ---------- selected files ---------- */

.filelist {
  display: none;
  flex-direction: column;
  gap: 7px;
  margin-top: 14px;
}
.filelist.show { display: flex; }

.filechip {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 15px;
  border-radius: 16px;
  background: var(--tsf);
  box-shadow: var(--sh-card);
  font-size: 13.5px;
  animation: as-in 0.25s var(--ease);
}
.filechip > svg { color: var(--tac); flex: none; stroke-width: 2.75; }
.filechip .fname {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}
.filechip .fsize {
  color: var(--tmu);
  font-size: 12.5px;
  flex: none;
  font-variant-numeric: tabular-nums;
}
.filechip button {
  border: none;
  background: none;
  color: var(--tmu);
  cursor: pointer;
  padding: 6px;
  margin: -6px -6px -6px 0;
  border-radius: 8px;
  display: grid;
  place-items: center;
  flex: none;
}
.filechip button svg { stroke-width: 2.75; }
.filechip button:hover { color: var(--tdg); }

.sendprompt {
  display: none;
  margin: 14px 0 0;
  text-align: center;
  color: var(--tac);
  font-size: 13.5px;
  font-weight: 600;
  animation: as-in 0.3s var(--ease);
}
.sendprompt.show { display: block; }

/* ---------- devices ---------- */

.devices { margin-top: 34px; }

.devices h3 {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--tmu);
}

.devicelist { display: flex; flex-direction: column; gap: 7px; }

.device {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 13px 16px;
  border: none;
  border-radius: var(--r-card);
  background: var(--tsf);
  box-shadow: var(--sh-card);
  color: var(--ttx);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.device:hover { background: var(--tas); }
.device:active { transform: scale(0.985); }
.device[disabled] { opacity: 0.55; cursor: default; }
.device[disabled]:hover { background: var(--tsf); }

.device .d-icon {
  width: 44px;
  height: 44px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: var(--r-tile);
  background: var(--tas);
  color: var(--tac);
}
.device .d-icon svg { stroke-width: 2.6; }

.device .d-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  text-align: start;
}
.device .d-name {
  font-weight: 600;
  font-size: 14.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.device .d-status {
  font-size: 12.5px;
  color: var(--tmu);
  display: flex;
  align-items: center;
  gap: 6px;
}
.device .dot {
  width: 7px;
  height: 7px;
  flex: none;
  border-radius: 50%;
  background: var(--tmu);
  opacity: 0.5;
}
.device.online .dot { background: var(--tok); opacity: 1; }
.device.online .d-status { color: var(--tok); }

/* chevron affordance — pure CSS, no extra DOM for app.js to manage */
.device::after {
  content: "";
  flex: none;
  width: 8px;
  height: 8px;
  margin-inline-start: 2px;
  border-top: 2.4px solid var(--tmu);
  border-right: 2.4px solid var(--tmu);
  border-radius: 1px;
  transform: rotate(45deg);
  opacity: 0;
  transition: opacity var(--dur) var(--ease);
}
/* only meaningful once files are staged and the device can actually receive */
#sendprompt.show ~ .devices .device.online::after { opacity: 0.75; }

.empty {
  padding: 26px 22px;
  border-radius: var(--r-card);
  background: var(--tsf);
  box-shadow: var(--sh-card);
  text-align: center;
  color: var(--tmu);
  font-size: 13.5px;
  line-height: 1.65;
}
.empty p { margin: 0 0 18px; }

.pairrow {
  display: flex;
  justify-content: center;
  margin-top: 16px;
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 12px 24px;
  border: none;
  border-radius: var(--r-pill);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: filter var(--dur) var(--ease), color var(--dur) var(--ease),
    border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.btn:active { transform: scale(0.97); }

.btn-primary { background: var(--tac); color: #ffffff; }
.btn-primary:hover { filter: brightness(1.06); }

.btn-ghost { background: transparent; color: var(--tmu); }
.btn-ghost:hover { color: var(--ttx); }

.btn-danger-ghost { background: transparent; color: var(--tdg); }
.btn-danger-ghost:hover { filter: brightness(1.1); }

.btn-outline {
  min-height: 0;
  padding: 11px 22px;
  border: 1.5px solid var(--tbd);
  background: transparent;
  color: var(--ttx);
  font-size: 13.5px;
}
.btn-outline:hover { border-color: var(--tac); color: var(--tac); }
.btn-outline svg { stroke-width: 2.6; }

.btn-block { width: 100%; }

/* ---------- focus ---------- */

.dropzone:focus-visible,
.iconbtn:focus-visible,
.btn:focus-visible,
.device:focus-visible,
.filechip button:focus-visible {
  outline: 2.5px solid var(--tac);
  outline-offset: 2px;
}

/* ---------- scrim + sheets ---------- */

.scrim {
  position: fixed;
  inset: 0;
  background: var(--tscrim);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur) var(--ease);
  z-index: 40;
}
.scrim.show { opacity: 1; pointer-events: auto; }

.sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translate(-50%, 105%);
  width: min(100%, 460px);
  padding: 30px 28px calc(34px + env(safe-area-inset-bottom));
  border-radius: var(--r-sheet) var(--r-sheet) 0 0;
  background: var(--tsf);
  color: var(--ttx);
  box-shadow: var(--sh-sheet);
  transition: transform 280ms var(--ease);
  z-index: 50;
}
.sheet.show { transform: translate(-50%, 0); }

@media (min-width: 700px) {
  .sheet {
    bottom: auto;
    top: 50%;
    border-radius: var(--r-sheet);
    padding-bottom: 30px;
    transform: translate(-50%, -46%) scale(0.96);
    opacity: 0;
    pointer-events: none;
    box-shadow: 0 24px 60px rgba(32, 22, 8, 0.28);
    transition: transform 260ms var(--ease), opacity 200ms var(--ease);
  }
  .sheet.show {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
    pointer-events: auto;
  }
}

.sheet h2 {
  margin: 0 0 4px;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 400;
  letter-spacing: 0.2px;
  text-align: center;
}

.sheet .sub {
  margin: 0 0 14px;
  text-align: center;
  color: var(--tmu);
  font-size: 13.5px;
  overflow-wrap: anywhere;
}

.sheet .bigicon {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--tas);
  color: var(--tac);
  animation: as-in 0.3s var(--ease);
}
.sheet .bigicon svg { stroke-width: 2.6; }
.sheet .bigicon.ok { background: var(--ta2s); color: var(--ta2); }
.sheet .bigicon.err { background: var(--tas); color: var(--tdg); }
/* when the status icon is an indeterminate ring, drop the plate behind it */
.sheet .bigicon:has(.spinner) { background: transparent; }

.sheet .actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 18px;
}

/* ---------- progress ---------- */

.progresswrap { display: none; margin-top: 6px; }
.progresswrap.show { display: block; }

.progressbar {
  height: 8px;
  border-radius: 99px;
  background: var(--tas);
  overflow: hidden;
}
.progressbar > div {
  height: 100%;
  width: 0%;
  border-radius: 99px;
  background: var(--tac);
  transition: width 180ms linear;
}
.progresstext {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  font-size: 12.5px;
  color: var(--tmu);
  font-variant-numeric: tabular-nums;
}

/* ---------- spinner ---------- */

.spinner {
  width: 26px;
  height: 26px;
  border: 3px solid var(--tas);
  border-top-color: var(--tac);
  border-radius: 50%;
  animation: as-spin 0.9s linear infinite;
}
.spinner-sm { width: 16px; height: 16px; border-width: 2px; }
.bigicon .spinner { width: 64px; height: 64px; border-width: 4px; }

/* ---------- QR pairing ---------- */

.qrbox {
  width: 216px;
  height: 216px;
  margin: 0 auto 16px;
  padding: 14px;
  border-radius: 20px;
  background: var(--tqr);
  display: grid;
  place-items: center;
}
.qrbox svg { width: 100%; height: 100%; }

.pairlink {
  margin: 0 0 4px;
  text-align: center;
  font-size: 12.5px;
  color: var(--tmu);
  overflow-wrap: anywhere;
  user-select: all;
}

/* ---------- rename field ---------- */

.field {
  width: 100%;
  min-height: 48px;
  padding: 12px 18px;
  border: 1.5px solid var(--tbd);
  border-radius: var(--r-pill);
  background: var(--tbg);
  color: var(--ttx);
  font: inherit;
  font-size: 15px;
  outline: none;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.field:focus {
  border-color: var(--tac);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(26px + env(safe-area-inset-bottom));
  transform: translate(-50%, 14px);
  padding: 12px 22px;
  border-radius: var(--r-pill);
  background: var(--ttx);
  color: var(--tbg);
  font-size: 13.5px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
  z-index: 60;
  max-width: calc(100vw - 48px);
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- footnote ---------- */

.footnote {
  margin: auto 0 0;
  padding-top: 44px;
  text-align: center;
  font-size: 12px;
  line-height: 1.7;
  color: var(--tmu);
}

/* ---------- utilities ---------- */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  clip-path: inset(50%);
  overflow: hidden;
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
