/* Tabshir App: a toy walkie-talkie. Rules in ../DESIGN.md. */

@font-face { font-family: 'Bagel Fat One'; src: url(/fonts/bagel-fat-one.woff2) format('woff2'); font-display: swap; }
@font-face { font-family: 'Gabarito'; src: url(/fonts/gabarito.woff2) format('woff2'); font-weight: 400 900; font-display: swap; }

:root {
  --plastic: #FFF1DA; --plastic-2: #F6E2C2; --hole: #E3C9A0; --ink: #2A1B38; --ink-soft: #6B5A78;
  --sun: #FFC531; --sun-wall: #D99A00;
  --sea: #45AEF7; --sea-wall: #1C7CC4;
  --grape: #C77DF0; --grape-wall: #9147BD;
  --mint: #3ED8B2; --mint-wall: #18A584;
  --tomato: #FF6E50; --tomato-wall: #D2442A;
  --leaf: #82CF4E; --leaf-wall: #559C27;
  --bubble: #FF92C8; --bubble-wall: #D8619E;
  --ink-key: #2A1B38; --ink-key-wall: #0F0716; --ink-key-text: #FFF1DA;
  --sheet: #FFFFFF;
  --fun: 'Bagel Fat One', 'Arial Rounded MT Bold', system-ui, sans-serif;
  --ui: 'Gabarito', system-ui, -apple-system, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --plastic: #2A1B38; --plastic-2: #362548; --hole: #170D20; --ink: #FFF1DA; --ink-soft: #C9B7D6;
    --ink-key: #FFF1DA; --ink-key-wall: #BFA98A; --ink-key-text: #2A1B38; --sheet: #3A2850;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--plastic); color: var(--ink); }
body {
  font: 500 17px/1.4 var(--ui); min-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  -webkit-user-select: none; user-select: none; overscroll-behavior: none;
}
input, textarea { -webkit-user-select: text; user-select: text; }
button { font: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer; }
#app { max-width: 560px; margin: 0 auto; padding: 14px 16px 40px; }
h1, h2 { font-family: var(--fun); font-weight: 400; line-height: 1.05; margin: 0; letter-spacing: .005em; }
h1 { font-size: 2.3rem; }
h2 { font-size: 1.5rem; margin: 30px 0 12px; }
p { margin: 8px 0; }
.soft { color: var(--ink-soft); }

/* ---- the speaker grille: once per screen, where news comes out ---- */
.grille {
  position: relative; border-radius: 28px; padding: 18px 20px 20px; margin-bottom: 18px;
  background-color: var(--plastic-2);
  background-image: radial-gradient(circle at center, var(--hole) 0 3.2px, transparent 3.6px);
  background-size: 15px 15px; background-position: 4px 4px;
}
.grille > * { position: relative; }
.grille .say {
  display: inline-block; background: var(--plastic); border-radius: 18px; padding: 8px 14px;
  font-weight: 700; font-size: 1.05rem;
}
.grille .say b { font-family: var(--fun); font-weight: 400; }
.grille .hello { font-family: var(--fun); font-size: 2rem; display: inline-block; background: var(--plastic);
  border-radius: 18px; padding: 4px 14px 8px; margin-bottom: 10px; }

/* ---- the squishy key ---- */
.keys { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 14px; }
.key {
  --c: var(--sun); --w: var(--sun-wall); --t: var(--ink);
  position: relative; min-height: 132px; padding: 16px 12px 14px; color: var(--t); background: var(--c);
  box-shadow: 0 7px 0 var(--w); transform: translateY(0); transition: transform .08s, box-shadow .08s;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; text-align: center;
  font-family: var(--fun); font-size: 1.22rem; line-height: 1.02;
}
.key:active, .key.pressed { transform: translateY(6px); box-shadow: 0 1px 0 var(--w); }
.key.wobble { animation: wobble .45s ease-out; }
.key:focus-visible { outline: 3px dashed var(--ink); outline-offset: 5px; }
.key.wide { grid-column: span 2; min-height: 150px; flex-direction: row; gap: 16px; font-size: 1.8rem; }
.key.wide .glyph { width: 66px; height: 66px; }
.key.talk { min-height: 104px; font-size: 1.7rem; }
.key .glyph { width: 50px; height: 50px; flex: none; }
.c-sun { --c: var(--sun); --w: var(--sun-wall); }
.c-sea { --c: var(--sea); --w: var(--sea-wall); }
.c-grape { --c: var(--grape); --w: var(--grape-wall); }
.c-mint { --c: var(--mint); --w: var(--mint-wall); }
.c-tomato { --c: var(--tomato); --w: var(--tomato-wall); }
.c-leaf { --c: var(--leaf); --w: var(--leaf-wall); }
.c-bubble { --c: var(--bubble); --w: var(--bubble-wall); }
.c-ink { --c: var(--ink-key); --w: var(--ink-key-wall); --t: var(--ink-key-text); }

/* each key gets its own blob */
.b1 { border-radius: 58% 42% 46% 54% / 48% 56% 44% 52%; }
.b2 { border-radius: 40% 60% 55% 45% / 55% 45% 58% 42%; }
.b3 { border-radius: 52% 48% 38% 62% / 42% 58% 50% 50%; }
.b4 { border-radius: 46% 54% 62% 38% / 60% 40% 46% 54%; }
.b5 { border-radius: 62% 38% 50% 50% / 50% 50% 40% 60%; }
.b6 { border-radius: 44% 56% 48% 52% / 38% 62% 52% 48%; }
.b7 { border-radius: 50% 50% 58% 42% / 56% 44% 60% 40%; }
.b-wide { border-radius: 46px 70px 54px 64px / 64px 50px 70px 48px; }
.b-talk { border-radius: 999px; }

@keyframes wobble {
  0% { transform: translateY(6px) scale(1.04, .94); }
  40% { transform: translateY(-3px) scale(.97, 1.04); }
  70% { transform: translateY(1px) scale(1.01, .99); }
  100% { transform: none; }
}

/* glyph moves, one per shape */
.go .g-ring { animation: ring .5s ease-in-out 2; transform-origin: 50% 60%; }
.go .g-eyes { animation: look 1s ease-in-out; }
.go .g-door { animation: swing .9s ease-in-out; transform-origin: 30% 50%; transform-box: fill-box; }
.go .g-hop { animation: hop .6s ease-out 2; }
.go .g-pulse { animation: pulse .6s ease-out 2; transform-origin: center; transform-box: fill-box; }
.go .g-talk { animation: pulse .5s ease-out 2; transform-origin: center; transform-box: fill-box; }
@keyframes ring { 0%,100% { transform: rotate(0) } 20% { transform: rotate(-16deg) } 40% { transform: rotate(14deg) } 60% { transform: rotate(-10deg) } 80% { transform: rotate(6deg) } }
@keyframes look { 0%,100% { transform: translateX(0) } 25% { transform: translateX(-4px) } 65% { transform: translateX(4px) } }
@keyframes swing { 0%,100% { transform: scaleX(1) } 45% { transform: scaleX(.35) } }
@keyframes hop { 0%,100% { transform: translateY(0) } 40% { transform: translateY(-7px) } }
@keyframes pulse { 0%,100% { transform: scale(1) } 40% { transform: scale(1.2) } }

/* ---- pills: the small keys ---- */
.pill { text-decoration: none;
  display: inline-flex; align-items: center; gap: 8px; border-radius: 999px; padding: 11px 18px;
  background: var(--plastic-2); color: var(--ink); font-weight: 800; box-shadow: 0 3px 0 var(--hole);
  transition: transform .08s, box-shadow .08s;
}
.pill:active { transform: translateY(3px); box-shadow: 0 0 0 var(--hole); }
.pill.main { background: var(--ink-key); color: var(--ink-key-text); box-shadow: 0 4px 0 var(--ink-key-wall); }
.pill.main:active { box-shadow: 0 0 0 var(--ink-key-wall); transform: translateY(4px); }
.pill[aria-pressed="true"] { background: var(--ink-key); color: var(--ink-key-text); box-shadow: 0 3px 0 var(--ink-key-wall); }
.pill svg { width: 20px; height: 20px; }
.pills { display: flex; flex-wrap: wrap; gap: 10px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* ---- sheets: pair code, beam, reply ---- */
.sheet { background: var(--sheet); border-radius: 28px; padding: 22px 20px; }
.code-in {
  width: 100%; font: 400 2.6rem/1 var(--fun); letter-spacing: .28em; text-align: center; text-transform: uppercase;
  padding: 16px 8px 18px; border-radius: 22px; border: 3px solid var(--ink); background: var(--plastic); color: var(--ink);
}
.code-in:focus { outline: none; border-style: dashed; }
.code-big { font: 400 3.6rem/1 var(--fun); letter-spacing: .18em; text-align: center; margin: 10px 0; }
.text-in {
  width: 100%; font: 600 1.05rem var(--ui); padding: 13px 16px; border-radius: 18px; border: 2px solid var(--hole);
  background: var(--plastic); color: var(--ink);
}
.text-in:focus { outline: none; border-color: var(--ink); }
.err { color: var(--tomato-wall); font-weight: 700; }

/* beam overlay */
.beam {
  position: fixed; inset: 0; z-index: 10; background: var(--plastic); display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 24px 20px calc(24px + env(safe-area-inset-bottom)); text-align: center;
}
.beam .blob {
  --c: var(--sun); --w: var(--sun-wall);
  position: relative; width: 190px; height: 180px; display: grid; place-items: center; background: var(--c);
  box-shadow: 0 8px 0 var(--w); border-radius: 58% 42% 46% 54% / 48% 56% 44% 52%;
}
.beam .blob .glyph { width: 84px; height: 84px; }
.beam .ring { position: absolute; inset: -14px; border: 4px solid var(--c); border-radius: inherit; opacity: 0; }
.beam.sending .ring { animation: beam 1.3s ease-out infinite; }
.beam.sending .ring:nth-child(2) { animation-delay: .45s; }
@keyframes beam { 0% { transform: scale(.9); opacity: .9 } 100% { transform: scale(1.5); opacity: 0 } }
.beam h1 { margin-top: 30px; font-size: 2.4rem; }
.steps { list-style: none; padding: 0; margin: 18px 0 0; display: grid; gap: 8px; font-weight: 700; font-size: 1.1rem; }
.steps li { color: var(--ink-soft); }
.steps li.on { color: var(--ink); }
.steps li.on::before { content: ''; display: inline-block; width: 12px; height: 12px; border-radius: 50%; background: var(--leaf); margin-right: 8px; }
.reply-bubble {
  margin-top: 22px; background: var(--sheet); border-radius: 26px 26px 26px 8px; padding: 16px 20px; max-width: 320px;
  font-family: var(--fun); font-size: 1.55rem; line-height: 1.1; animation: pop .5s cubic-bezier(.2, 1.6, .4, 1);
}
.reply-bubble small { display: block; font: 700 .9rem var(--ui); color: var(--ink-soft); margin-bottom: 6px; }
@keyframes pop { 0% { transform: scale(.3) rotate(-8deg); opacity: 0 } 100% { transform: none; opacity: 1 } }
.beam .done { margin-top: 28px; }

/* ---- Tanvir's side ---- */
.alerts { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.alerts li button { width: 100%; text-align: left; display: flex; align-items: center; gap: 14px; padding: 12px 14px;
  border-radius: 22px; background: var(--plastic-2); }
.alerts .dot { width: 44px; height: 44px; flex: none; display: grid; place-items: center; background: var(--c); border-radius: 46% 54% 50% 50% / 52% 48% 52% 48%; color: var(--ink); }
.alerts .dot svg { width: 28px; height: 28px; }
.alerts .what { font-weight: 800; }
.alerts .when { font-size: .9rem; color: var(--ink-soft); }
.alerts .state { margin-left: auto; font-size: .88rem; font-weight: 700; color: var(--ink-soft); text-align: right; }
.alerts .new .state { color: var(--tomato-wall); }

.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.card {
  min-height: 92px; padding: 14px 12px; border-radius: 22px; background: var(--c); color: var(--ink); box-shadow: 0 5px 0 var(--w);
  font-family: var(--fun); font-size: 1.08rem; line-height: 1.08; text-align: left; transition: transform .08s, box-shadow .08s;
}
.card:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--w); }
.card:nth-child(4n+2) { border-radius: 30px 18px 26px 20px; }
.card:nth-child(4n+3) { border-radius: 18px 30px 20px 28px; }
.devices { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.devices li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 2px dotted var(--hole); }
.my-cards li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 2px dotted var(--hole); }
.my-cards { list-style: none; padding: 0; margin: 10px 0; }
.x { font-weight: 800; color: var(--tomato-wall); padding: 6px 10px; }

.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink-key); color: var(--ink-key-text); padding: 12px 20px; border-radius: 999px; font-weight: 800; z-index: 20;
  animation: pop .4s cubic-bezier(.2, 1.6, .4, 1); }

.howto { list-style: none; padding: 0; margin: 18px 0; display: grid; gap: 14px; counter-reset: s; }
.howto li { counter-increment: s; display: flex; gap: 14px; align-items: center; font-weight: 700; font-size: 1.1rem; }
.howto li::before { content: counter(s); flex: none; width: 42px; height: 42px; display: grid; place-items: center;
  font: 400 1.4rem var(--fun); background: var(--sun); box-shadow: 0 4px 0 var(--sun-wall); border-radius: 50% 46% 54% 50%; }
.howto svg { width: 24px; height: 24px; vertical-align: -5px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media (max-width: 360px) { .key { font-size: 1.08rem; min-height: 118px; } .key.wide { font-size: 1.5rem; } }
.c-ink .glyph { color: var(--ink-key); }
.c-ink .glyph [fill="#FFF8EC"] { fill: var(--sun); }
.key:not(.wide) span { padding: 0 6px; }
