/* ============================================================
   Tryon Tools — Base tokens, glassmorphism, layout
   ============================================================ */
:root {
  --background: 0 0% 3%;
  --foreground: 0 0% 92%;
  --card: 0 0% 7%;
  --muted: 0 0% 12%;
  --muted-foreground: 0 0% 55%;
  --primary: 185 80% 55%;
  --primary-foreground: 0 0% 3%;
  --secondary: 260 60% 55%;
  --accent: 330 70% 55%;
  --border: 0 0% 15%;
  --ring: 185 80% 55%;
  --layer-glow: 185 80% 55%;
  --radius: 0.75rem;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  font-family: 'Space Grotesk', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

img { -webkit-user-drag: none; user-select: none; pointer-events: none; max-width: 100%; }
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea { font: inherit; }
.font-mono, code { font-family: 'JetBrains Mono', ui-monospace, monospace; }

/* ---------- Canvas & layer transforms ---------- */
.canvas {
  position: fixed; inset: 0;
  overflow: hidden;
  perspective: 1200px;
  perspective-origin: center center;
  touch-action: none;
  cursor: grab;
}
.canvas.dragging { cursor: grabbing; }

.layer-wrap {
  position: absolute; inset: 0;
  transform-style: preserve-3d;
  transition: transform 300ms ease-out, filter 300ms ease-out, opacity 300ms ease-out;
  will-change: transform, opacity, filter;
}
.layer-wrap.no-transition { transition: none !important; }
.layer-wrap.inactive { pointer-events: none; }

.tile {
  position: absolute;
  width: 300vw; height: 300vh;
}

/* ---------- Layer content shell ---------- */
.layer-content {
  position: relative;
  width: 300vw; height: 300vh;
  display: flex; flex-direction: column;
}
.layer-bg {
  position: absolute; inset: 0; z-index: 0;
  background-color: var(--layer-bg-base);
  background-image:
    repeating-linear-gradient(45deg, var(--layer-bg-color) 0 .5px, transparent .5px 8px),
    repeating-linear-gradient(-45deg, var(--layer-bg-color) 0 .5px, transparent .5px 8px),
    radial-gradient(circle .8px at 6px 6px, var(--layer-bg-accent, var(--layer-bg-color)) 100%, transparent 100%),
    repeating-linear-gradient(0deg, transparent 0 3px, var(--layer-bg-color) 3px 3.3px, transparent 3.3px 12px);
  background-size: 11px 11px, 11px 11px, 12px 12px, 100% 12px;
  opacity: var(--bg-opacity, 1);
  transition: opacity .15s ease;
}
.layer-grid {
  position: relative; z-index: 1;
  flex: 1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  min-height: 300vh; min-width: 300vw;
}
.cell { display: flex; align-items: center; justify-content: center; padding: clamp(1rem, 4vw, 3rem); position: relative; }
.cell-center { min-height: 100vh; }

/* ---------- Glass panel ---------- */
.glass {
  background: hsl(var(--card) / .7);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid hsl(var(--border) / .3);
  border-radius: var(--radius);
  box-shadow:
    0 0 30px hsl(var(--layer-glow) / .05),
    inset 0 1px 0 hsl(0 0% 100% / .05);
}
.glow-text { text-shadow: 0 0 20px hsl(var(--primary) / .5), 0 0 40px hsl(var(--primary) / .2); }
.glow-border { box-shadow: 0 0 15px hsl(var(--primary) / .15), 0 0 30px hsl(var(--primary) / .05); }

.vignette-fade {
  -webkit-mask-image: radial-gradient(ellipse 60% 60% at center, black 20%, transparent 70%);
  mask-image: radial-gradient(ellipse 60% 60% at center, black 20%, transparent 70%);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .75rem 1.25rem; border-radius: .5rem;
  font-family: 'JetBrains Mono', monospace; font-size: .75rem; letter-spacing: .12em;
  text-transform: uppercase;
  transition: transform .2s, background .2s, box-shadow .2s;
  min-height: 44px; min-width: 44px;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); }
.btn-primary:hover { background: hsl(var(--primary) / .85); }
.btn-secondary { background: hsl(var(--secondary)); color: white; }
.btn-accent { background: hsl(var(--accent)); color: white; }
.btn-outline { border: 1px solid hsl(var(--primary) / .4); color: hsl(var(--primary)); }
.btn-outline:hover { background: hsl(var(--primary) / .1); }

/* ---------- Inputs ---------- */
.input, .textarea {
  width: 100%;
  background: hsl(var(--card) / .5);
  border: 1px solid hsl(var(--border) / .5);
  color: hsl(var(--foreground));
  padding: .75rem 1rem;
  border-radius: .5rem;
  outline: none;
}
.input::placeholder, .textarea::placeholder { color: hsl(var(--muted-foreground)); }
.input:focus-visible, .textarea:focus-visible { border-color: hsl(var(--primary)); box-shadow: 0 0 0 3px hsl(var(--primary) / .2); }
.textarea { min-height: 120px; resize: vertical; }

.chip {
  display: inline-block; padding: .25rem .75rem; border-radius: 999px;
  font-family: 'JetBrains Mono', monospace; font-size: .7rem;
  background: hsl(var(--card) / .7); border: 1px solid hsl(var(--border) / .4);
  color: hsl(var(--foreground));
}

/* ---------- Header / Footer ---------- */
.layer-header {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem;
  padding: clamp(.75rem, 2vw, 1.25rem) clamp(1rem, 3vw, 2rem);
  padding-top: max(env(safe-area-inset-top), .75rem);
  background: hsl(var(--background) / .85);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid hsl(var(--border) / .3);
  width: 100vw;
}
.layer-header .brand { display: flex; align-items: center; gap: .75rem; }
.layer-header .logo {
  width: 40px; height: 40px; border-radius: .5rem;
  background: hsl(var(--primary) / .2); border: 1px solid hsl(var(--primary) / .5);
  display: flex; align-items: center; justify-content: center;
  color: hsl(var(--primary)); font-weight: 700;
}
.layer-header h1 { font-size: .95rem; font-weight: 700; letter-spacing: .02em; }
.layer-header .tagline { font-size: .65rem; letter-spacing: .4em; color: hsl(var(--primary)); font-family: 'JetBrains Mono', monospace; }
.layer-header nav { display: none; gap: 1.5rem; }
.layer-header nav span { font-size: .75rem; font-family: 'JetBrains Mono', monospace; color: hsl(var(--muted-foreground)); letter-spacing: .12em; text-transform: uppercase; cursor: pointer; transition: color .2s; }
.layer-header nav span:hover, .layer-header nav span.active { color: hsl(var(--primary)); }
.layer-header .layer-counter { font-size: .7rem; font-family: 'JetBrains Mono', monospace; color: hsl(var(--muted-foreground)); }
@media (min-width: 1024px) { .layer-header nav { display: flex; } }

.layer-footer {
  width: 100vw;
  padding: clamp(1rem, 2vw, 1.5rem);
  padding-bottom: max(env(safe-area-inset-bottom), 1rem);
  background: hsl(var(--card) / .7);
  backdrop-filter: blur(20px);
  border-top: 1px solid hsl(var(--border) / .3);
  display: flex; flex-direction: column; align-items: center; gap: .75rem;
}
.layer-footer .socials { display: flex; gap: 1rem; color: hsl(var(--muted-foreground)); }
.layer-footer .socials a:hover { color: hsl(var(--primary)); }
.layer-footer .copy { font-size: .7rem; font-family: 'JetBrains Mono', monospace; color: hsl(var(--muted-foreground)); }
@media (min-width: 640px) { .layer-footer { flex-direction: row; justify-content: space-between; } }

/* ---------- Overlay UI ---------- */
.overlay { position: fixed; inset: 0; z-index: 100; pointer-events: none; }
.overlay > * { pointer-events: auto; }

.arrow {
  position: fixed;
  width: 44px; height: 44px; border-radius: 999px;
  background: hsl(var(--card) / .7);
  backdrop-filter: blur(20px);
  border: 1px solid hsl(var(--border) / .3);
  color: hsl(var(--primary));
  font-size: 1.1rem;
  display: flex; align-items: center; justify-content: center;
  transition: background .2s, color .2s, box-shadow .2s;
  cursor: pointer;
}
/* Pressed-look on hover/active without moving the button */
.arrow:hover, .arrow:active {
  background: hsl(var(--primary) / .25);
  color: hsl(var(--foreground));
  box-shadow: inset 0 0 12px hsl(var(--primary) / .35), 0 0 14px hsl(var(--primary) / .35);
}
.arrow-up    { top: 1rem;    left: calc(50% - 22px); }
.arrow-down  { bottom: 1rem; left: calc(50% - 22px); }
.arrow-left  { left: 1rem;   top: calc(50% - 22px); }
.arrow-right { right: 1rem;  top: calc(50% - 22px); }

.hint {
  position: fixed; top: 1rem; left: 1rem;
  max-width: 70vw;
  padding: .5rem .75rem;
  background: hsl(var(--card) / .7); backdrop-filter: blur(20px);
  border: 1px solid hsl(var(--border) / .3); border-radius: .5rem;
  font-size: .65rem; font-family: 'JetBrains Mono', monospace;
  color: hsl(var(--muted-foreground)); line-height: 1.5;
  display: none;
}
@media (min-width: 768px) { .hint { display: block; } }

.topright {
  position: fixed; top: 1rem; right: 1rem;
  display: flex; align-items: center; gap: .5rem;
}
.toggles, .lang {
  display: flex; gap: .25rem;
  padding: .25rem;
  background: hsl(var(--card) / .7); backdrop-filter: blur(20px);
  border: 1px solid hsl(var(--border) / .3); border-radius: .5rem;
}
.toggles .mode, .lang button {
  min-width: 36px; min-height: 36px; padding: .35rem .55rem;
  border-radius: .35rem;
  font-family: 'JetBrains Mono', monospace; font-size: .75rem;
  color: hsl(var(--muted-foreground));
  transition: all .2s;
}
.toggles .mode.active, .lang button.active {
  background: hsl(var(--primary) / .2); color: hsl(var(--primary));
  box-shadow: 0 0 12px hsl(var(--primary) / .35);
}
.toggles .mode:hover, .lang button:hover { color: hsl(var(--primary)); }

.indicator {
  position: fixed; bottom: 1rem; right: 1rem;
  display: flex; align-items: center; gap: .75rem;
  padding: .5rem 1rem;
  background: hsl(var(--card) / .7); backdrop-filter: blur(20px);
  border: 1px solid hsl(var(--border) / .3); border-radius: .5rem;
}
.dots { display: flex; gap: .35rem; }
.dot {
  width: 10px; height: 10px; border-radius: 999px;
  background: hsl(var(--muted-foreground) / .4);
  transition: all .2s;
}
.dot.active { background: hsl(var(--primary)); box-shadow: 0 0 12px hsl(var(--primary) / .8); }
.dot:hover { transform: scale(1.25); }
.layer-name { font-size: .75rem; font-family: 'JetBrains Mono', monospace; color: hsl(var(--muted-foreground)); }

/* ---------- Focus visible ---------- */
:focus-visible { outline: 2px solid hsl(var(--primary)); outline-offset: 2px; }

/* ---------- Toasts ---------- */
.toast-wrap {
  position: fixed; bottom: 5rem; left: 50%; transform: translateX(-50%);
  z-index: 200; display: flex; flex-direction: column; gap: .5rem;
  pointer-events: none;
}
.toast {
  background: hsl(var(--card) / .9); backdrop-filter: blur(20px);
  border: 1px solid hsl(var(--primary) / .4); color: hsl(var(--foreground));
  padding: .75rem 1.25rem; border-radius: .5rem;
  font-size: .85rem;
  box-shadow: 0 10px 40px rgba(0,0,0,.4);
  animation: toast-in .25s ease-out;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* ---------- Animations for layer transitions ---------- */
@keyframes dive-in  { 0% { transform: scale(1); opacity: 1; } 100% { transform: scale(2); opacity: 0; } }
@keyframes emerge   { 0% { transform: scale(.5); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
.transitioning-in  { animation: dive-in .6s ease-in-out forwards; }
.transitioning-out { animation: emerge  .6s ease-in-out forwards; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
