/* shared/ui.css
   Robbie PRO design system for the diet and walk apps.
   Brand rules (Brand Kits/רובי פרו/brand.md): only Night, Lavender, White and their tints.
   No red, no green, no other colour, also not for status. FbBooster for all text,
   Matritsa Narrow Black only for numbers and codes. English labels mark, Hebrew speaks. */

@font-face { font-family: 'Booster'; src: url('/shared/fonts/FbBooster-Regular.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Booster'; src: url('/shared/fonts/FbBooster-Medium.woff2') format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Booster'; src: url('/shared/fonts/FbBooster-Bold.woff2') format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Booster'; src: url('/shared/fonts/FbBooster-Black.woff2') format('woff2'); font-weight: 900; font-display: swap; }
@font-face { font-family: 'Matritsa'; src: url('/shared/fonts/FbMatritsaNarrowEnHeb-Black.woff2') format('woff2'); font-weight: 900; font-display: swap; }

:root {
    --night: #12191C;
    --night-80: #3A4043;
    --night-60: #717577;
    --night-40: #A0A3A4;
    --night-20: #D0D1D2;
    --lav: #9D8AC1;
    --lav-80: #B1A1CD;
    --lav-60: #C4B9DA;
    --lav-20: #EBE8F3;
    --white: #FFFFFF;

    --bg: var(--night);
    --surface: #182024;          /* Night with a touch of white, still inside the Night family */
    --surface-2: #1F272B;
    --line: rgba(255, 255, 255, 0.09);
    --line-strong: rgba(255, 255, 255, 0.16);
    --text: var(--white);
    --muted: var(--night-40);
    --faint: var(--night-60);

    --r-card: 18px;
    --r-ctl: 12px;
    --pad: 20px;
    --gap: 14px;

    --font: 'Booster', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --num: 'Matritsa', 'Booster', sans-serif;

    color-scheme: dark;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
    font-family: var(--font);
    font-weight: 400;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    min-height: 100dvh;
    direction: rtl;
    line-height: 1.35;
    -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }

.app {
    max-width: 480px;
    margin: 0 auto;
    padding: calc(env(safe-area-inset-top, 0px) + 18px) 16px calc(env(safe-area-inset-bottom, 0px) + 32px);
    display: flex;
    flex-direction: column;
    gap: var(--gap);
}

/* ---- type ---- */
.eyebrow {
    font-weight: 500;
    font-size: 11px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--lav);
    direction: ltr;
    unicode-bidi: isolate;
}
.title { font-weight: 900; font-size: 28px; line-height: 1.1; }
.h2 { font-weight: 900; font-size: 18px; line-height: 1.2; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-family: var(--num); font-weight: 900; letter-spacing: 0.01em; direction: ltr; unicode-bidi: isolate; }

/* ---- header ---- */
.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; padding: 4px 4px 6px; }
.topbar .eyebrow { margin-bottom: 4px; }
.icon-btn {
    width: 42px; height: 42px; flex: none;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 50%;
    border: 1px solid var(--line);
    background: transparent;
    color: var(--white);
}
.icon-btn:active { background: var(--surface-2); }
a.icon-btn { text-decoration: none; }
.icon-btn.sm { width: 34px; height: 34px; border: none; color: var(--muted); }

/* ---- icons: brand set rules, 24 grid, stroke 1.5, one lavender detail ---- */
.ic { width: 22px; height: 22px; flex: none; display: block; }
.ic path, .ic g { stroke-width: 1.5; }
.ic .acc { stroke: var(--lav); }
.ic.sm { width: 18px; height: 18px; }

/* ---- card ---- */
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-card);
    padding: var(--pad);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 16px; }
.card-head .eyebrow { margin-bottom: 3px; }

/* ---- the ticket: body + perforation + stub (brand "lying card") ----
   RTL: body on the right, stub on the left. Notches sit on both ends of the perforation. */
.ticket {
    --notch: 11px;
    position: relative;
    display: grid;
    grid-template-columns: 1fr 34%;
    border-radius: var(--r-card);
    min-height: 168px;
    isolation: isolate;
}
.ticket-body {
    background: var(--night-80);
    border-radius: 0 var(--r-card) var(--r-card) 0;
    padding: 20px 20px 18px;
    display: flex; flex-direction: column; justify-content: space-between; gap: 12px;
    -webkit-mask: radial-gradient(circle var(--notch) at 0 0, transparent 98%, #000) top left / 100% 51% no-repeat,
                  radial-gradient(circle var(--notch) at 0 100%, transparent 98%, #000) bottom left / 100% 51% no-repeat;
            mask: radial-gradient(circle var(--notch) at 0 0, transparent 98%, #000) top left / 100% 51% no-repeat,
                  radial-gradient(circle var(--notch) at 0 100%, transparent 98%, #000) bottom left / 100% 51% no-repeat;
}
.ticket-stub {
    background: var(--lav);
    color: var(--night);
    border-radius: var(--r-card) 0 0 var(--r-card);
    padding: 20px 14px 18px;
    display: flex; flex-direction: column; justify-content: space-between; align-items: center; text-align: center; gap: 8px;
    -webkit-mask: radial-gradient(circle var(--notch) at 100% 0, transparent 98%, #000) top right / 100% 51% no-repeat,
                  radial-gradient(circle var(--notch) at 100% 100%, transparent 98%, #000) bottom right / 100% 51% no-repeat;
            mask: radial-gradient(circle var(--notch) at 100% 0, transparent 98%, #000) top right / 100% 51% no-repeat,
                  radial-gradient(circle var(--notch) at 100% 100%, transparent 98%, #000) bottom right / 100% 51% no-repeat;
}
.ticket-stub .eyebrow { color: var(--night); opacity: 0.75; }
.ticket::after { /* the perforation, a shape of rounded dashes */
    content: '';
    position: absolute;
    top: calc(var(--notch) + 6px); bottom: calc(var(--notch) + 6px);
    left: 34%;
    width: 2px; margin-left: -1px;
    background: repeating-linear-gradient(to bottom, var(--lav) 0 7px, transparent 7px 12px);
    border-radius: 2px;
    z-index: 1;
}
.ticket .big { white-space: nowrap; font-family: var(--num); font-weight: 900; font-size: 64px; line-height: 0.9; direction: ltr; unicode-bidi: isolate; }
.ticket .big small { font-family: var(--font); font-weight: 400; font-size: 16px; margin-inline-start: 6px; color: var(--muted); }
.ticket-stub .mid { font-family: var(--num); font-weight: 900; font-size: 34px; line-height: 0.95; direction: ltr; }
.code { display: inline-flex; align-items: center; gap: 6px; font-family: var(--num); font-weight: 900; font-size: 15px; letter-spacing: 0.06em; direction: ltr; }
.code .plane { width: 13px; height: 13px; }

/* ---- progress rail ---- */
.rail { height: 4px; background: var(--line-strong); border-radius: 4px; overflow: hidden; }
.rail > i { display: block; height: 100%; background: var(--lav); border-radius: 4px; transition: width .5s ease; }

/* ---- data block (brand: English label, value, lavender hairlines above and below) ---- */
.datablock {
    display: grid; grid-template-columns: repeat(2, 1fr);
    border-top: 1px solid var(--lav); border-bottom: 1px solid var(--lav);
}
.datablock > div { padding: 14px 4px 13px; position: relative; }
.datablock > div:nth-child(odd)::after { content: ''; position: absolute; left: 0; top: 14px; bottom: 14px; width: 1px; background: var(--line-strong); }
.datablock > div:nth-child(n+3) { border-top: 1px solid var(--line); }
.datablock > div:nth-child(even) { padding-inline-start: 16px; }
.datablock .eyebrow { margin-bottom: 6px; }
.datablock .val { font-family: var(--num); font-weight: 900; font-size: 26px; line-height: 1; direction: ltr; unicode-bidi: isolate; display: inline-block; }
.datablock .val small { font-family: var(--font); font-weight: 400; font-size: 13px; color: var(--muted); margin-inline-start: 4px; }
.datablock .note { font-size: 12px; color: var(--muted); margin-top: 5px; }

/* ---- form controls ---- */
.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.field > label, .field > .label { font-size: 13px; color: var(--muted); }
.input, .datebtn {
    display: flex; align-items: center; gap: 10px;
    width: 100%; min-width: 0; height: 52px;
    padding: 0 14px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--r-ctl);
    color: var(--text);
    font-size: 17px;
    outline: none;
    -webkit-appearance: none; appearance: none;
}
.input:focus, .datebtn:focus-within { border-color: var(--lav); }
input.input[type=number] { font-family: var(--num); font-weight: 900; font-size: 22px; letter-spacing: 0.02em; text-align: center; direction: ltr; }
input[type=number]::-webkit-inner-spin-button, input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number] { -moz-appearance: textfield; }

/* Date: iOS Safari gives input[type=date] its own width and ignores width/appearance,
   so the native input is laid invisibly over a styled button that shows the date. */
.datebtn { position: relative; justify-content: space-between; }
.datebtn .datetext { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.datebtn input[type=date] {
    position: absolute; inset: 0;
    width: 100%; height: 100%; min-width: 0;
    opacity: 0; border: 0; padding: 0; margin: 0;
    -webkit-appearance: none; appearance: none;
    font-size: 16px; /* >= 16px: no iOS zoom */
}
.datebtn input[type=date]::-webkit-calendar-picker-indicator { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }

.stepper { display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; gap: 6px; height: 52px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-ctl); padding: 0 4px; }
.stepper:focus-within { border-color: var(--lav); }
.stepper button { height: 44px; border: none; background: transparent; color: var(--white); border-radius: 10px; display: flex; align-items: center; justify-content: center; }
.stepper button:active { background: var(--night-80); }
.stepper input { width: 100%; min-width: 0; height: 100%; border: none; background: transparent; outline: none; text-align: center; font-family: var(--num); font-weight: 900; font-size: 26px; direction: ltr; -webkit-appearance: none; appearance: none; }

.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stack { display: flex; flex-direction: column; gap: 12px; }

/* ---- buttons ---- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    width: 100%; height: 52px; padding: 0 18px;
    border-radius: var(--r-ctl);
    border: 1px solid transparent;
    font-weight: 700; font-size: 16px;
    transition: transform .12s ease, background-color .2s ease, opacity .2s ease;
}
.btn:active { transform: scale(0.985); }
.btn:disabled { opacity: 0.45; }
.btn-primary { background: var(--lav); color: var(--night); }
.btn-primary .ic .acc, .btn-primary .ic { stroke: var(--night); color: var(--night); }
.btn-ghost { background: transparent; color: var(--white); border-color: var(--line-strong); }
.btn-quiet { background: transparent; color: var(--muted); height: 44px; }

/* ---- segmented control ---- */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { height: 32px; border: none; background: transparent; color: var(--muted); border-radius: 8px; font-size: 13px; font-weight: 500; }
.seg button.on { background: var(--night-80); color: var(--white); }

/* ---- list ---- */
.list { display: flex; flex-direction: column; }
.list-row { display: grid; grid-template-columns: 1fr auto auto 34px; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.list-row:first-child { border-top: none; }
.list-row .w { font-family: var(--num); font-weight: 900; font-size: 18px; direction: ltr; }
.delta { display: inline-flex; align-items: center; gap: 3px; font-size: 13px; direction: ltr; min-width: 58px; justify-content: flex-end; }
.delta.down { color: var(--lav); }
.delta.up { color: var(--muted); }

/* ---- message toast ---- */
.toast {
    position: fixed; left: 50%; top: calc(env(safe-area-inset-top, 0px) + 14px);
    transform: translate(-50%, -20px); opacity: 0; pointer-events: none;
    background: var(--white); color: var(--night);
    padding: 12px 18px; border-radius: 999px; font-weight: 500; font-size: 14px;
    display: inline-flex; align-items: center; gap: 8px;
    transition: opacity .25s ease, transform .25s ease;
    z-index: 50; white-space: nowrap;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast button { border: none; background: none; color: var(--night); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }

/* ---- bottom sheet (settings, past day) ---- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(8, 11, 13, 0.6); opacity: 0; pointer-events: none; transition: opacity .2s ease; z-index: 40; }
.sheet {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 41;
    max-width: 480px; margin: 0 auto;
    background: var(--surface); border: 1px solid var(--line); border-bottom: none;
    border-radius: 22px 22px 0 0;
    padding: 10px 20px calc(env(safe-area-inset-bottom, 0px) + 22px);
    transform: translateY(105%); transition: transform .28s cubic-bezier(.2,.8,.2,1);
}
.sheet::before { content: ''; display: block; width: 38px; height: 4px; border-radius: 4px; background: var(--line-strong); margin: 0 auto 16px; }
.sheet.open { transform: translateY(0); }
.sheet-backdrop.open { opacity: 1; pointer-events: auto; }

.hidden { display: none !important; }
.center { text-align: center; }
.spin { width: 18px; height: 18px; border: 2px solid currentColor; border-top-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
