/* Calculatorul de fibre Sipit. Culorile și regulile vin din brandbook. */

@font-face {
  font-family: 'Baloo 2';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url('fonts/baloo2-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-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Baloo 2';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url('fonts/baloo2-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;
}

:root {
  --verde: #3CA75B;        /* Sipit green: butoane, titluri pe alb, logo */
  --val: #58BB7A;          /* Wave green */
  --roz: #F4ACCD;          /* Watermelon pink */
  --crem: #F2E1CB;         /* Studio cream */
  --hartie: #FBF4EA;       /* crem deschis, fundalul paginii */
  --alb: #FFFFFF;
  --cerneala: #1E2A20;     /* text */
  --cerneala-2: #4A574D;   /* text secundar */
  --linie: #E9DCC8;
  --verde-pal: #E3F3E8;
  --bleu: #CDE6F3;
  --r: 8px;
  --ease-pop: cubic-bezier(.34, 1.56, .64, 1);
}

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

html, body {
  margin: 0;
  min-height: 100%;
  overscroll-behavior: none;
}

body {
  font-family: 'Baloo 2', ui-rounded, 'Arial Rounded MT Bold', 'Varela Round', 'Nunito', 'Segoe UI', system-ui, sans-serif;
  font-size: 18px;
  line-height: 1.45;
  color: var(--cerneala);
  background: var(--hartie);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

h1, h2, h3, p, ul, ol, dl, dd { margin: 0; padding: 0; }
ul, ol { list-style: none; }
img { display: block; max-width: 100%; }
button, input { font: inherit; color: inherit; }
button { touch-action: manipulation; }
[hidden] { display: none !important; }

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

:focus-visible { outline: 3px solid var(--cerneala); outline-offset: 2px; }
h1:focus { outline: none; }

/* ---------- Butoane ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 56px; padding: 8px 24px;
  border: 0; border-radius: var(--r);
  font-size: 20px; font-weight: 600; line-height: 1.15; text-align: center; text-decoration: none;
  cursor: pointer; user-select: none; -webkit-user-select: none;
  transition: transform .18s var(--ease-pop), background-color .15s;
}
.btn:active { transform: scale(.96); }
.btn-primary { background: var(--verde); color: var(--alb); }
.btn-secondary { background: var(--alb); color: #000; border: 1.5px solid #CDBFA9; }
.btn-wide { width: 100%; }
.btn[disabled] { cursor: default; transform: none; }
.btn-primary[disabled] { background: #A9B5AB; }
.btn-secondary[disabled] { background: var(--verde-pal); border-color: var(--verde); }

/* ---------- Ecrane ---------- */
.view { display: none; flex-direction: column; min-height: 100vh; min-height: 100dvh; }
.view.is-active { display: flex; animation: view-in .32s var(--ease-pop) both; }
@keyframes view-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.topbar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 2;
  display: flex; justify-content: center; padding: 12px 16px 0;
  pointer-events: none;
}
.logo { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; pointer-events: auto; }
.logo-small { width: 84px; height: auto; }

.wrap { width: 100%; max-width: 1180px; margin: 0 auto; padding: 84px 16px 24px; flex: 1 0 auto; }
.wrap-narrow { max-width: 640px; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }

h1 { font-size: clamp(30px, 7.4vw, 42px); line-height: 1.08; font-weight: 800; letter-spacing: -.01em; }
h2 { font-size: 20px; line-height: 1.2; font-weight: 600; }
.title-green { color: var(--verde); }
.lead { font-size: 20px; line-height: 1.35; font-weight: 500; }
.fine { font-size: 15px; line-height: 1.4; color: var(--cerneala-2); }

.panel { background: var(--alb); border-radius: var(--r); padding: 16px; }

/* ---------- 1. Start ---------- */
.view-start { position: relative; overflow: hidden; background: var(--val); }
.waves { position: absolute; inset: 0; width: 100%; height: 100%; }
.start-inner {
  position: relative; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: clamp(20px, 5vh, 44px);
  padding: 32px 20px calc(32px + env(safe-area-inset-bottom));
}
.logo-hero { width: min(64vw, 330px); height: auto; }
.sticker {
  width: 100%; max-width: 440px;
  background: var(--alb); border-radius: var(--r);
  padding: 24px 22px 22px; text-align: center;
  transform: rotate(-1.5deg);
}
.sticker h1 { color: var(--verde); font-size: clamp(36px, 10vw, 50px); line-height: 1.02; }
.sticker-sub { margin: 12px 0 20px; font-size: 20px; font-weight: 500; }

/* ---------- 2. Ce ai mâncat azi? ---------- */
#view-plate h1 { margin-bottom: 16px; }
.write-label { display: block; font-size: 20px; font-weight: 600; margin-bottom: 8px; }
.write-row { display: flex; flex-direction: column; gap: 8px; }
@media (min-width: 560px) { .write-row { flex-direction: row; } }
.write-input {
  flex: 1 1 auto; min-width: 0; min-height: 56px; padding: 8px 14px;
  font-size: 18px; /* cel puțin 16 px, ca telefonul să nu facă zoom la focus */
  background: var(--alb); border: 2px solid var(--cerneala); border-radius: var(--r);
}
.write-input::placeholder { color: #6B766D; opacity: 1; }
.write-input:focus-visible { outline: 3px solid var(--verde); outline-offset: 1px; }
.status { min-height: 0; font-size: 17px; font-weight: 500; }
.status:not(:empty) { margin-top: 10px; }
.write .fine { margin-top: 10px; }

.plate { margin-top: 20px; }
.plate h2 { margin-bottom: 8px; }
.chips { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.chip {
  display: flex; align-items: center; gap: 8px; width: 100%; height: 100%;
  min-height: 56px; padding: 6px 10px 6px 12px;
  background: var(--alb); border: 1.5px solid var(--linie); border-radius: var(--r);
  text-align: left; cursor: pointer;
  user-select: none; -webkit-user-select: none;
  animation: pop-in .35s var(--ease-pop) both;
}
.chip:active { transform: scale(.96); }
.chip-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; line-height: 1.15; }
.chip-text b { font-size: 16px; font-weight: 600; }
.chip-text span { font-size: 14px; color: var(--cerneala-2); }
.chip-g { flex: 0 0 auto; font-size: 15px; font-weight: 700; white-space: nowrap; background: var(--verde-pal); border-radius: 999px; padding: 3px 8px; }
.chip-x { flex: 0 0 auto; font-size: 22px; font-weight: 600; line-height: 1; }
@keyframes pop-in { from { opacity: 0; transform: scale(.8); } to { opacity: 1; transform: none; } }

.sep { display: flex; align-items: center; gap: 12px; margin: 24px 0 8px; font-size: 18px; font-weight: 600; color: var(--cerneala-2); }
.sep::before, .sep::after { content: ''; flex: 1; height: 2px; background: var(--linie); border-radius: 2px; }

.cat { margin-top: 18px; }
.cat h2 { margin-bottom: 10px; }
.cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }

.card { position: relative; }
.card-add {
  display: flex; flex-direction: column; align-items: flex-start; gap: 8px;
  width: 100%; height: 100%; min-height: 128px; padding: 12px 12px 14px;
  background: var(--alb); border: 2px solid var(--linie); border-radius: var(--r);
  text-align: left; cursor: pointer;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  transition: transform .18s var(--ease-pop), border-color .15s, background-color .15s;
}
.card-add:active { transform: scale(.96); }
.card-add[aria-pressed="true"] { border-color: var(--verde); background: var(--verde-pal); }
.card-emoji {
  display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%;
  font-size: 26px; line-height: 1; background: var(--crem);
}
.cat-1 .card-emoji { background: var(--crem); }
.cat-2 .card-emoji { background: #CFEBD8; }
.cat-3 .card-emoji { background: var(--roz); }
.cat-4 .card-emoji { background: var(--bleu); }
.card-add[aria-pressed="true"] .card-emoji { background: var(--alb); }
.card-name { font-size: 17px; font-weight: 600; line-height: 1.15; }
.card-portion { font-size: 15px; line-height: 1.2; color: var(--cerneala-2); margin-top: -4px; }
.card-count {
  position: absolute; top: 10px; right: 10px; min-width: 40px; padding: 4px 8px;
  background: var(--roz); border-radius: 999px; text-align: center;
  font-size: 17px; font-weight: 700; line-height: 1.2; pointer-events: none;
  animation: pop-in .3s var(--ease-pop) both;
}
.card-minus {
  position: absolute; right: 0; bottom: 0; width: 56px; height: 56px;
  display: grid; place-items: center; border: 0; background: none; cursor: pointer; border-radius: var(--r);
}
.card-minus span {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%;
  background: var(--alb); border: 2px solid var(--cerneala);
  font-size: 24px; font-weight: 600; line-height: 1; padding-bottom: 3px;
}
.card.is-full .card-add { animation: nudge .3s; }
@keyframes nudge { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

.pop {
  position: absolute; left: 50%; top: 34%; z-index: 3; pointer-events: none;
  padding: 4px 12px; border-radius: 999px; white-space: nowrap;
  background: var(--cerneala); color: var(--alb); font-size: 20px; font-weight: 700;
  animation: pop-up .8s var(--ease-pop) both;
}
@keyframes pop-up {
  0% { opacity: 0; transform: translate(-50%, 10px) scale(.6); }
  30% { opacity: 1; transform: translate(-50%, -14px) scale(1.1); }
  70% { opacity: 1; transform: translate(-50%, -22px) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -40px) scale(.9); }
}

/* ---------- Bara de jos ---------- */
.dock {
  position: sticky; bottom: 0; z-index: 4; margin-top: auto;
  background: var(--alb); border-top: 2px solid var(--linie);
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
}
.dock-inner {
  max-width: 1148px; margin: 0 auto;
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px 14px;
}
.dock-inner .bar { grid-column: 1 / -1; }
.dock-single { display: block; max-width: 608px; text-align: center; }
.dock-total { font-size: 20px; font-weight: 500; white-space: nowrap; }
.dock-total strong { font-size: 26px; font-weight: 700; }
.countdown { margin-top: 8px; }
body.typing .dock { display: none; } /* tastatura de pe ecran e deschisă: nu acoperim câmpul */

/* ---------- Bara de progres, cu marginea ca un val ---------- */
.bar {
  position: relative; display: flex; height: 22px; overflow: hidden;
  background: var(--crem); border-radius: var(--r);
}
.bar-lg { height: 34px; margin-top: 12px; }
.bar-fill {
  position: relative; flex: 0 0 auto; width: 0; height: 100%; background: var(--verde);
  transition: width .9s var(--ease-pop);
}
.bar-fill::after {
  content: ''; position: absolute; top: 0; bottom: 0; left: calc(100% - 1px); width: 14px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='28' viewBox='0 0 14 28'%3E%3Cpath d='M0 0H7C14 7 0 21 7 28H0Z' fill='%233CA75B'/%3E%3C/svg%3E") repeat-y 0 0 / 14px 28px;
  animation: wave-run 1.4s linear infinite;
}
.bar-fill.is-empty::after { display: none; }
.bar-sipit { background: var(--roz); z-index: 1; }
.bar-sipit::after {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='28' viewBox='0 0 14 28'%3E%3Cpath d='M0 0H7C14 7 0 21 7 28H0Z' fill='%23F4ACCD'/%3E%3C/svg%3E");
}
#res-fill { z-index: 2; }
@keyframes wave-run { to { background-position: 0 28px; } }
.bar-mark { position: absolute; top: 0; bottom: 0; z-index: 3; width: 2px; background: var(--cerneala); }
.bar-mark span {
  position: absolute; top: 50%; right: 6px; transform: translateY(-50%);
  font-size: 15px; font-weight: 700; line-height: 1; color: var(--cerneala);
}

/* ---------- 3. Rezultat ---------- */
.result-hero { text-align: center; padding: 20px 16px; }
.big { color: var(--verde); font-weight: 800; line-height: .95; letter-spacing: -.02em; font-size: clamp(34px, 9vw, 46px); }
.big-num { font-size: clamp(88px, 27vw, 132px); }
.big-unit { font-size: clamp(48px, 14vw, 70px); }
.big-of { display: block; margin-top: 4px; }
.result-hero .lead { margin-top: 16px; }
.sipit-row { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 16px; min-height: 124px; }
.can {
  flex: 0 0 auto; width: 0; height: 124px; opacity: 0; overflow: hidden; border-radius: var(--r);
  transform: translateX(120px) rotate(12deg);
  transition: transform .7s var(--ease-pop), opacity .25s, width .3s;
}
.can img { width: 86px; height: 124px; object-fit: cover; border-radius: var(--r); }
.can.is-in { width: 86px; opacity: 1; transform: none; }

.from { margin-top: 22px; }
.from h2 { margin-bottom: 8px; }
.rows { background: var(--alb); border-radius: var(--r); padding: 2px 14px; }
.row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1.5px solid var(--linie); font-size: 17px; }
.row:last-child { border-bottom: 0; }
.row-name b { font-weight: 600; }
.row-name span { color: var(--cerneala-2); }
.row-g { font-weight: 700; white-space: nowrap; }
.row-sipit { animation: pop-in .4s var(--ease-pop) both; }
.row-sipit .row-g { background: var(--roz); border-radius: 999px; padding: 2px 10px; }
.note { margin-top: 18px; text-align: center; }

/* ---------- 4a. Abonare ---------- */
.sub-card { padding: 28px 20px; }
.sub-card h1 { margin-bottom: 20px; }
.qr { width: min(56vw, 300px); margin: 0 auto 16px; }
.qr svg { display: block; width: 100%; height: auto; }
.kiosk-only { display: none; }
html.kiosk .kiosk-only { display: block; }
html.kiosk .phone-only { display: none; }

/* ---------- 4b. Final ---------- */
#view-final h1 { max-width: 16em; margin: 0 auto 22px; }
.flavours { display: grid; grid-template-columns: 1fr; gap: 12px; max-width: 900px; margin: 0 auto; }
.flavour {
  position: relative; overflow: hidden; border-radius: var(--r);
  display: flex; align-items: center; gap: 14px; padding: 12px 14px; min-height: 120px; text-align: left;
}
.flavour::before {
  content: ''; position: absolute; inset: 0;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 400 200' preserveAspectRatio='none'%3E%3Cpath d='M0 120C70 70 120 90 180 130C250 176 300 60 400 30V200H0Z'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 400 200' preserveAspectRatio='none'%3E%3Cpath d='M0 120C70 70 120 90 180 130C250 176 300 60 400 30V200H0Z'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
}
.flavour img { position: relative; flex: 0 0 auto; width: 66px; height: 96px; object-fit: cover; border-radius: var(--r); }
.flavour p {
  position: relative; font-size: 21px; font-weight: 700; line-height: 1.12;
  background: var(--alb); color: #000; border-radius: var(--r); padding: 8px 12px;
}
.flavour-pepene { background: #F4ACCD; }
.flavour-pepene::before { background: #3CA75B; }
.flavour-zmeura { background: #CDE6F3; }
.flavour-zmeura::before { background: #E3161B; }
.flavour-prune { background: #FD6C00; }
.flavour-prune::before { background: #2E2A9E; }

/* ---------- Panoul cu cifre ---------- */
.stats { width: min(92vw, 560px); max-height: 86dvh; padding: 20px; border: 2px solid var(--cerneala); border-radius: var(--r); background: var(--alb); color: var(--cerneala); }
.stats::backdrop { background: rgba(30, 42, 32, .55); }
.stats h2 { font-size: 24px; margin-bottom: 12px; }
.stats h3 { font-size: 17px; font-weight: 600; margin: 14px 0 6px; }
.stats-list { display: grid; grid-template-columns: 1fr auto; gap: 6px 16px; font-size: 17px; }
.stats-list dd { font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.stats-foods { font-size: 16px; columns: 2; column-gap: 20px; }
.stats-foods li { display: flex; justify-content: space-between; gap: 8px; break-inside: avoid; padding: 2px 0; }
.stats-foods b { font-variant-numeric: tabular-nums; }
.stats-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.stats-actions .btn { flex: 1 1 auto; }

.noscript { padding: 24px; text-align: center; }

/* ---------- Mod kiosk ---------- */
html.kiosk body { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
html.kiosk .write-input { user-select: text; -webkit-user-select: text; }

/* ---------- Tabletă ---------- */
@media (min-width: 600px) {
  .flavours { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .flavour { flex-direction: column; justify-content: flex-end; gap: 12px; padding: 18px 14px 16px; min-height: 300px; text-align: center; }
  .flavour::before {
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 300 300' preserveAspectRatio='none'%3E%3Cpath d='M0 150C60 110 100 130 150 165C205 205 245 100 300 85V300H0Z'/%3E%3C/svg%3E");
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 300 300' preserveAspectRatio='none'%3E%3Cpath d='M0 150C60 110 100 130 150 165C205 205 245 100 300 85V300H0Z'/%3E%3C/svg%3E");
  }
  .flavour img { width: 110px; height: 160px; }
}

@media (min-width: 768px) {
  body { font-size: 19px; }
  .wrap { padding-left: 24px; padding-right: 24px; }
  .cards { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
  .chips { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .write { padding: 20px; }
  .dock { padding-left: 24px; padding-right: 24px; }
  .dock-inner { grid-template-columns: 1fr auto auto; gap: 18px; }
  .dock-inner .bar { grid-column: auto; height: 26px; }
  .dock-single { display: block; }
  .sticker { padding: 32px 30px 28px; max-width: 520px; }
  .sticker h1 { font-size: 56px; }
  .logo-hero { width: min(40vw, 380px); }
  .qr { width: 300px; }
}

@media (min-width: 1000px) {
  .cards { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}

/* Tabletă pe lat, ecran scund: ținem ecranul de start și rezultatul într-o singură privire */
@media (min-width: 768px) and (max-height: 820px) and (orientation: landscape) {
  .start-inner { flex-direction: row; gap: 48px; }
  .logo-hero { width: min(34vw, 360px); }
  .big-num { font-size: 104px; }
  .flavour { min-height: 250px; }
  .flavour img { width: 92px; height: 134px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .pop { animation: pop-still .9s both !important; }
  @keyframes pop-still { 0%, 80% { opacity: 1; transform: translate(-50%, -14px); } 100% { opacity: 0; transform: translate(-50%, -14px); } }
}
