/* =========================================================================
   Tutok — Base: reset, typography, device frame, layout scaffold, utilities
   ========================================================================= */

/* ---- Modern reset ---- */
*,
*::before,
*::after { box-sizing: border-box; }

* { margin: 0; }

html, body { height: 100%; overflow-x: hidden; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: var(--font-text);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  color: var(--ink);
  background: var(--ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

img, svg, video, canvas { display: block; max-width: 100%; }
img { height: auto; }

input, button, textarea, select {
  font: inherit;
  color: inherit;
}

button { background: none; border: none; cursor: pointer; }

a { color: inherit; text-decoration: none; }

ul, ol { list-style: none; padding: 0; }

p, h1, h2, h3, h4, h5, h6 { overflow-wrap: break-word; }

h1, h2, h3, h4 {
  font-family: var(--font-display);
  line-height: var(--lh-tight);
  font-weight: 700;
  letter-spacing: -0.01em;
}

:focus { outline: none; }

/* Accessible focus ring everywhere */
:focus-visible {
  outline: 2.5px solid var(--brand);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

::selection {
  background: color-mix(in srgb, var(--brand) 28%, transparent);
  color: var(--ink);
}

/* =========================================================================
   App backdrop + device stage (desktop shows a phone on a violet gradient)
   ========================================================================= */
.app-bg {
  min-height: 100dvh;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: clamp(0px, 4vw, 56px);
  background:
    radial-gradient(120% 90% at 15% 0%, rgba(124,58,237,.55) 0%, transparent 55%),
    radial-gradient(120% 90% at 100% 100%, rgba(91,91,245,.55) 0%, transparent 55%),
    linear-gradient(160deg, #241d4a 0%, #15112c 60%, #100d22 100%);
  background-attachment: fixed;
}

.app-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-4);
}

.app-caption {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--fs-sm);
  letter-spacing: .01em;
  color: rgba(255,255,255,.72);
}
.app-caption__mark { display: inline-flex; filter: drop-shadow(0 2px 6px rgba(168,85,247,.5)); }

/* ---- The phone device frame ---- */
.phone {
  position: relative;
  width: min(var(--frame-w), 100%);
  height: min(932px, calc(100dvh - 80px));
  background: #0c0a18;
  border-radius: 54px;
  padding: 12px;
  box-shadow:
    var(--sh-pop),
    0 0 0 2px rgba(255,255,255,.06),
    0 0 0 11px #1a1730,
    0 0 0 12px rgba(255,255,255,.04);
}

/* Notch / camera pill */
.phone::before {
  content: "";
  position: absolute;
  top: 22px;
  left: 50%;
  transform: translateX(-50%);
  width: 116px;
  height: 30px;
  background: #0c0a18;
  border-radius: var(--r-pill);
  z-index: 30;
  pointer-events: none;
}

.phone__screen {
  position: relative;
  height: 100%;
  width: 100%;
  background: var(--bg);
  border-radius: 42px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  isolation: isolate;
}

/* =========================================================================
   Status bar
   ========================================================================= */
.statusbar {
  flex: 0 0 auto;
  height: 46px;
  padding: 0 28px 0 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--ink);
  font-family: var(--font-display);
  position: relative;
  z-index: 20;
  padding-top: env(safe-area-inset-top, 0);
}
.statusbar__time {
  font-weight: 700;
  font-size: 0.9375rem;
  letter-spacing: .02em;
}
.statusbar__icons {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.statusbar__glyph { fill: var(--ink); }
.statusbar__battery { fill: var(--ink); }

/* =========================================================================
   Scrollable app region
   ========================================================================= */
.app-root {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  scrollbar-width: none;
  position: relative;
  scroll-behavior: smooth;
  /* Bottom nav is an in-flow sibling that reserves its own height + safe-area,
     so app-root must NOT add nav height here (that created a dead gap above the
     nav, most visible under the full-height chat composer). Safe-area only. */
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.app-root::-webkit-scrollbar { width: 0; height: 0; display: none; }

/* When a flow screen hides the nav, screens add .no-nav on app-root via app.js */
.app-root.no-nav { padding-bottom: env(safe-area-inset-bottom, 0px); }

/* Standard inner padding wrapper used by screens */
.screen {
  padding: var(--s-4) var(--s-4) var(--s-6);
}
.screen--flush { padding: 0 0 var(--s-6); }

/* =========================================================================
   Host layers
   ========================================================================= */
.sheet-root { position: absolute; inset: 0; z-index: var(--z-sheet); pointer-events: none; }
.sheet-root:empty { display: none; }

.toast-root {
  position: absolute;
  left: 0; right: 0;
  bottom: calc(var(--nav-h) + 18px + env(safe-area-inset-bottom, 0px));
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-2);
  pointer-events: none;
  padding: 0 var(--s-4);
}

/* =========================================================================
   Utilities
   ========================================================================= */
.row { display: flex; align-items: center; }
.row--between { justify-content: space-between; }
.row--wrap { flex-wrap: wrap; }
.col { display: flex; flex-direction: column; }
.stack > * + * { margin-top: var(--s-3); }
.center { display: grid; place-items: center; text-align: center; }
.grow { flex: 1 1 auto; min-width: 0; }

.gap-1 { gap: var(--s-1); }
.gap-2 { gap: var(--s-2); }
.gap-3 { gap: var(--s-3); }
.gap-4 { gap: var(--s-4); }
.gap-5 { gap: var(--s-5); }

.muted { color: var(--muted); }
.ink-soft { color: var(--ink-soft); }
.text-sm { font-size: var(--fs-sm); }
.text-xs { font-size: var(--fs-xs); }
.text-brand { color: var(--brand); }
.fw-700 { font-weight: 700; }
.fw-800 { font-weight: 800; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.scroll-x {
  display: flex;
  gap: var(--s-3);
  overflow-x: auto;
  scrollbar-width: none;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
  padding-bottom: var(--s-1);
}
.scroll-x::-webkit-scrollbar { display: none; }
.scroll-x > * { scroll-snap-align: start; flex: 0 0 auto; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* =========================================================================
   Responsive: full-bleed device on phones & tablets (no bezel)
   Breakpoint covers all phones/phablets (many report 430-500px CSS width)
   and small tablets; the decorative phone mockup is desktop-only.
   ========================================================================= */
@media (max-width: 768px) {
  .app-bg {
    padding: 0;
    background: var(--bg);
    display: block;
    min-height: 100dvh;
  }
  .app-stage { gap: 0; width: 100%; display: block; }
  .phone {
    width: 100%;
    max-width: 100%;
    height: 100vh;   /* fallback */
    height: 100dvh;  /* preferred: tracks mobile browser chrome */
    border-radius: 0;
    padding: 0;
    box-shadow: none;
  }
  .phone::before { display: none; }
  .phone__screen { border-radius: 0; }
  .app-caption { display: none; }
}

/* Very large screens: keep the phone honest, just more breathing room */
@media (min-width: 1600px) {
  .app-bg { padding: 72px; }
}
