/* App-wide styles for Venire Balance (linked from index.html).
   Note: css/app.css is the unused Blazor template stylesheet and is NOT linked. */

/* Shared design tokens (UI style guide) */
:root {
    --ths-primary-tint: var(--ths-brand-tint);   /* chips, selected rows/tiles, subtle highlights */
}

/* ── Typography roles (see CLAUDE.md "UI text roles") ─────────────────
   Caption: labels a number or a section (gadget headers, "SNACKS", "HABITS").
   Title:   something you open or act on (Breakfast, a snack's time).      */
.ths-caption {
    margin: 0;
    font-size: var(--ths-fs-sm);
    font-weight: 600;
    line-height: 1.3;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--mud-palette-text-secondary);
}

/* Tile label: the name on small data tiles (macros, vitamins, Diet Balance pillars).
   Sentence case on purpose: softer than the uppercase captions. */
.ths-tile-label {
    margin: 0;
    font-size: var(--ths-fs-sm);
    font-weight: 500;
    line-height: 1.3;
    color: var(--mud-palette-text-secondary);
}

.ths-title {
    margin: 0;
    font-size: var(--ths-fs-md);
    font-weight: 600;
    line-height: 1.3;
    color: var(--mud-palette-text-primary);
}

/* Diary / Insights tiles: arrow cursor over plain text (not the text-input caret).
   cursor is inherited, so buttons and links keep their own pointer. */
.insight-row {
    cursor: default;
}

/* ── Loading screen (index.html, before Blazor starts) ─────────────────
   Blazor sets --blazor-load-percentage / --blazor-load-percentage-text on :root. */
.ths-loading {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    background: var(--ths-bg);
    font-family: Inter, Helvetica, Arial, sans-serif;
}

.ths-loading-ring {
    width: 72px;
    height: 72px;
    transform: rotate(-90deg);
}

.ths-loading-ring circle {
    fill: none;
    stroke-width: 8;
}

.ths-loading-ring circle:first-child {
    stroke: var(--ths-brand-tint);
}

.ths-loading-ring circle:last-child {
    stroke: var(--ths-brand);
    stroke-linecap: round;
    /* 100x100 viewBox: 1% = 1 unit, and pathLength="100" makes the ring 100 units long */
    stroke-dasharray: var(--blazor-load-percentage, 0%) 100;
    transition: stroke-dasharray 0.1s ease-out;
}

.ths-loading-name {
    font-size: var(--ths-fs-xl);
    font-weight: 600;
    color: var(--ths-text);
    letter-spacing: -0.01em;
}

.ths-loading-text {
    font-size: var(--ths-fs-sm);
    color: var(--ths-text-2);
}

.ths-loading-text::after {
    content: var(--blazor-load-percentage-text, "");
}

/* ── Unhandled-error bar (index.html); Blazor shows it on a crash ──── */
#blazor-error-ui {
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2000;
    padding: 10px 48px 10px 16px;
    background: var(--ths-low-tint);
    color: var(--ths-text);
    font-size: var(--ths-fs-md);
    box-shadow: 0 -1px 3px rgba(0, 0, 0, 0.15);
}

#blazor-error-ui .reload {
    color: var(--ths-brand-strong);
    font-weight: 600;
    margin-left: 8px;
}

#blazor-error-ui .dismiss {
    position: absolute;
    right: 16px;
    top: 10px;
    cursor: pointer;
}

/* ── Confidence dots (Shared/ConfidenceDots.razor, Specs/ConfidenceModel.md) ── */
.ths-conf-wrap { position: relative; display: inline-flex; align-items: center; pointer-events: auto; }
.ths-conf {
    display: inline-flex; gap: 3px; align-items: center;
    padding: 4px 2px; margin: 0; border: 0; background: none; cursor: pointer;
}
.ths-conf-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ths-neutral); }
.ths-conf-dot.on { background: var(--ths-brand); }
.ths-conf-pop { padding: 12px 16px; max-width: 280px; }
.ths-conf-line { font-size: var(--ths-fs-sm); color: var(--ths-text-2); margin-top: 4px; }
/* Diary: a past day logged only partly (day weight < 1) */
.ths-partial-day {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: var(--ths-fs-sm); color: var(--ths-text-2); background: var(--ths-track); border-radius: 12px; padding: 2px 8px;
}

/* Forecast: a gadget page showing a future day's plan (Shared/ForecastBanner.razor) */
.ths-forecast-banner {
    display: flex; gap: 12px; align-items: flex-start;
    border: 1px dashed rgba(32,178,170,0.7); background: var(--ths-primary-tint);
    border-radius: 8px; padding: 12px 16px; margin-bottom: 16px;
}
.ths-forecast-text { font-size: var(--ths-fs-sm); color: var(--ths-text-2); margin-top: 2px; }
.ths-forecast-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.ths-forecast-link {
    font-size: var(--ths-fs-sm); font-weight: 600; color: var(--ths-brand-strong); background: var(--ths-surface);
    border: 1px solid rgba(32,178,170,0.5); border-radius: 16px; padding: 4px 12px; cursor: pointer;
}
.ths-forecast-link:hover { background: var(--ths-brand-tint); }

/* Insights (Shared/InsightList.razor) */
.ths-insights { display: flex; flex-direction: column; gap: 8px; }
.ths-insight {
    display: flex; gap: 12px; align-items: stretch;
    background: var(--mud-palette-surface); border: 1px solid var(--ths-line-soft);
    border-radius: var(--ths-radius-tile); padding: 12px 16px;
}
.ths-insight-mark { width: 4px; border-radius: 2px; flex-shrink: 0; background: var(--ths-neutral); }
.ths-insight-overlimit    { background: var(--ths-nova-4); }
.ths-insight-gap,
.ths-insight-consistency  { background: #F5A623; }
.ths-insight-weeklytarget { background: #7FD3CE; }
.ths-insight-positive     { background: var(--ths-brand); }
.ths-insight-nudge        { background: var(--ths-neutral); }
.ths-insight-body { flex: 1; min-width: 0; }
.ths-insight-text { font-size: var(--ths-fs-md); line-height: 1.45; color: var(--ths-text); margin: 0; }
/* Date bars: a fixed-width slot between the chevrons (the date and, on gadget pages, the confidence
   dots), so the chevrons stay put whatever the date's length (Services/DateLabel) */
.ths-datebar-slot {
    width: 11rem; display: flex; align-items: center; justify-content: center; gap: 4px;
    white-space: nowrap; overflow: hidden;
}
.ths-datebar-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; }

/* The Food Score's picks, one at a time (Shared/InsightList: swipe or tap a dot) */
.ths-insight-carousel { touch-action: pan-y; }
.ths-carousel-dots { display: flex; justify-content: center; gap: 0; padding-top: 2px; }
.ths-carousel-dot {   /* an 8 px dot in a 24 px tap area */
    width: 8px; height: 8px; padding: 8px; box-sizing: content-box; border: 0; border-radius: 50%;
    background: var(--ths-neutral); background-clip: content-box; cursor: pointer;
}
.ths-carousel-dot-on { background: var(--ths-text-2); }   /* darker grey, same size: teal dots are the confidence score */
/* No focus ring or tap highlight around the 24 px tap area: it looked like a bigger dot. Keyboard focus darkens the dot. */
.ths-carousel-dot { -webkit-tap-highlight-color: transparent; }
.ths-carousel-dot:focus { outline: none; }
.ths-carousel-dot:focus-visible { background-color: var(--ths-text-2); }
.ths-insight-rest { margin-top: 2px; }
.ths-insight-tip {
    border: 0; background: none; padding: 0; margin-top: 4px; cursor: pointer; text-align: left;
    font-size: var(--ths-fs-sm); line-height: 1.4; color: var(--ths-brand-strong);
}
.ths-insight-tip:hover { text-decoration: underline; }
.ths-insight-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 4px; }
.ths-insight-link {
    border: 0; background: none; cursor: pointer; color: var(--ths-text-2); padding: 4px; border-radius: 4px;
}
.ths-insight-link:hover { background: var(--ths-primary-tint); color: var(--ths-brand-strong); }

/* One insight on a gadget front card (Shared/InsightLine.razor) */
.ths-insight-line { border-top: 1px solid var(--ths-line-soft); margin-top: 12px; padding-top: 8px; display: flex; flex-direction: column; gap: 2px; }
.ths-insight-line-head { display: flex; align-items: center; gap: 6px; }
.ths-insight-line-head .ths-insight-mark { width: 3px; height: 12px; }
.ths-insight-line-text { font-size: var(--ths-fs-md); line-height: 1.4; color: var(--ths-text); margin: 0; }

/* A gadget card's empty day (Shared/EmptyDay): the same line on every card, today in italics */
.ths-empty-day { margin: 0; font-size: var(--ths-fs-md); line-height: 1.4; color: var(--ths-text); }
.ths-empty-day-today { font-style: italic; color: var(--mud-palette-text-secondary); }

/* Recent foods + saved meals tile grid */
.recent-row {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 10px;
}

.recent-tile {
    position: relative;
    border-radius: var(--ths-radius-tile);
    border: 1px solid var(--ths-line-soft);
    background: var(--mud-palette-surface);
    overflow: hidden;
}

.recent-tile-body {
    padding: 12px 12px 10px;
    cursor: pointer;
    position: relative;
    z-index: 0;
}

.recent-tile-body:hover {
    background: rgba(32, 178, 170, 0.05);
}

.recent-tile-add {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--mud-palette-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1;
    transition: opacity 0.15s, transform 0.1s;
}

.recent-tile-add:hover {
    opacity: 0.85;
    transform: scale(1.1);
}

.recent-tile-name {
    font-size: var(--ths-fs-md);
    font-weight: 500;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding-right: 32px;
    margin-bottom: 3px;
}

.recent-tile-sub {
    font-size: var(--ths-fs-micro);
    color: var(--mud-palette-text-secondary);
    margin-bottom: 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.recent-tile-nutr {
    display: flex;
    gap: 2px;
    padding-top: 6px;
    border-top: 1px solid var(--ths-line-soft);
}

.recent-nutr-cell {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 0;
}

.recent-nutr-value {
    font-size: var(--ths-fs-sm);
    font-weight: 600;
    line-height: 1.1;
    white-space: nowrap;
}

.recent-nutr-label {
    font-size: var(--ths-fs-micro);
    color: var(--mud-palette-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.02em;
    margin-top: 1px;
    white-space: nowrap;
}

/* Meal tile — amber accent */
.meal-tile {
    border-left: 3px solid var(--ths-low);
    background: rgba(245, 158, 11, 0.03);
}

.meal-tile .recent-tile-body:hover {
    background: rgba(245, 158, 11, 0.07);
}

.meal-tile-add {
    background: var(--ths-low) !important;
}

/* Edit / delete row on a card */
.recent-tile-actions {
    display: flex;
    justify-content: flex-end;
    gap: 2px;
    padding: 0 6px 4px;
}

/* Small "Meal" badge inside meal tile */
.recent-tile-badge {
    display: inline-block;
    font-size: var(--ths-fs-micro);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--ths-low-text);
    background: rgba(245, 158, 11, 0.15);
    border-radius: 3px;
    padding: 1px 5px;
    margin-bottom: 4px;
}

/* Show more button row */
.recent-show-more {
    display: flex;
    justify-content: center;
}

/* Chart text in SVGs drawn at a fixed width (Food Groups, ...). A phone shows them at about half
   size, so the scale and the side headers grow there; labels under bars stay (they'd overlap). */
.ths-chart-axis {
    font: 500 10px Inter, Helvetica, Arial, sans-serif;
    fill: var(--ths-text-2);
}

.ths-chart-zone {
    font: 700 11px Inter, Helvetica, Arial, sans-serif;
    fill: var(--ths-text-2);
    letter-spacing: .04em;
}

/* Short labels under thin bars (A, D, B12, Ca): these can grow, long names can't */
.ths-chart-tick {
    font: 600 10px Inter, Helvetica, Arial, sans-serif;
    fill: var(--ths-text-2);
}

.ths-chart-tick-sel {
    font-weight: 700;
    fill: var(--ths-text);
}

@media (max-width: 600px) {
    .ths-chart-tick { font-size: 14px; fill: var(--ths-text); }
    .ths-chart-tick-sel { fill: var(--ths-text); }
    .ths-chart-axis { font-size: 18px; fill: var(--ths-text); }
    .ths-chart-zone { font-size: 22px; fill: var(--ths-text); }
}

/* Bottom navigation on phones (Shared/BottomNav). Below 960 px the sidebar is a drawer behind the
   top-left menu, out of thumb reach; the bar keeps the main sections at the bottom. */
.ths-bottomnav {
    display: none;
}

@media (max-width: 959.98px) {
    .ths-bottomnav {
        display: flex;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1100;
        height: calc(60px + env(safe-area-inset-bottom, 0px));
        padding-bottom: env(safe-area-inset-bottom, 0px);
        background: var(--mud-palette-surface);
        border-top: 1px solid var(--mud-palette-divider);
    }

    .ths-bottomnav a {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        font-size: var(--ths-fs-sm);
        color: var(--mud-palette-text-secondary);
        text-decoration: none;
    }

    .ths-bottomnav a.active {
        color: var(--ths-brand-strong);
        font-weight: 600;
    }

    /* Room for the bar at the end of every page */
    .mud-main-content {
        padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px));
    }

    /* No top bar on a phone (owner 2026-11-16, like most consumer apps): the bottom bar navigates, and the
       side menu's only extra, Admin, is in Settings. The page starts at the top (below a notch, if any). */
    .mud-appbar, .mud-drawer, .mud-drawer-overlay { display: none !important; }
    .mud-main-content { padding-top: env(safe-area-inset-top, 0px) !important; }
}

/* Settings goal pages (Shared/GoalField): one column on a phone, two when there's room */
.goal-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

@media (min-width: 700px) {
    .goal-grid { grid-template-columns: 1fr 1fr; }
}

/* Tips: a navigation word (Diary, Today, Settings → …) stands out, so the reader finds it in the app */
.tip-nav { color: var(--ths-brand-strong); font-weight: 700; }

/* A shared copy's origin on a meal / recipe tile ("Originally from Coach Anna"): small, quiet */
.recent-tile-origin { font-size: var(--ths-fs-micro); color: var(--ths-brand-strong); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Printing (the weekly report's Print / Save as PDF): only the page, without the app around it */
@media print {
    .mud-appbar, .mud-drawer, .ths-bottomnav, .txt-fab, .no-print, .mud-snackbar-provider { display: none !important; }
    .mud-main-content { padding: 0 !important; margin: 0 !important; }
    .mud-container { padding: 0 !important; max-width: none !important; }
    body { background: var(--ths-surface) !important; }
}

/* MudBlazor's cards (MudPaper) are cards: 12 px (owner 2026-11-16); its menus and popovers keep 8 px */
.mud-paper:not(.mud-popover):not(.mud-menu-list) { border-radius: var(--ths-radius-card); }

/* Headings get focus after each navigation (App.razor FocusOnNavigate, for screen readers): no outline on
   them, as in the Blazor template's app.css, which this app doesn't link. The tip screen's title showed a
   black rectangle (2026-11-18). Headings aren't interactive, so nothing is lost for keyboard users. */
h1:focus, h2:focus { outline: none; }

/* Source pill (Shared/SourcePill): Fineli / Open Food Facts / own, a quiet grey label next to the group and NOVA chips */
.mud-chip.ths-source-pill {
    background: var(--ths-track);
    color: var(--ths-text-2);
}
.mud-chip.ths-source-pill.ths-pill-compact {
    height: 18px;
    font-size: var(--ths-fs-micro);
}

/* ── Venire loader (Shared/VenireLoader): the start screen's teal arc, turning ── */
.ths-loader { display: inline-flex; }
.ths-loader-page { display: flex; justify-content: center; padding: var(--ths-space-4) 0; }
.ths-loader svg { width: 36px; height: 36px; animation: ths-loader-turn 0.9s linear infinite; }
.ths-loader-small { vertical-align: middle; }
.ths-loader-small svg { width: 18px; height: 18px; }
.ths-loader circle { fill: none; stroke-width: 10; }
.ths-loader circle:first-child { stroke: var(--ths-brand-tint); }
.ths-loader circle:last-child { stroke: var(--ths-brand); stroke-linecap: round; stroke-dasharray: 28 72; }
@keyframes ths-loader-turn { to { transform: rotate(360deg); } }
/* Reduced motion: a slow turn still says "working" */
@media (prefers-reduced-motion: reduce) { .ths-loader svg { animation-duration: 2.4s; } }

/* A scanned product's "Ingredients" row (Shared/IngredientsRow), under its name and chips: to the full-screen list */
.ths-ingredients-row {
    display: flex; align-items: center; justify-content: space-between;
    padding: var(--ths-space-3) var(--ths-space-4);
    background: var(--mud-palette-surface);
    border-radius: var(--ths-radius-tile);
    box-shadow: var(--ths-shadow-1);
    cursor: pointer; color: var(--ths-text-2);
}
.ths-ingredients-row .ths-title { color: var(--ths-text); }

/* Big "other ways to add" buttons (scan, describe) in the meal and recipe editors (Shared/FoodListEditor);
   the same look as the Log page's (.log-way) */
.ths-add-ways { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 14px; }
.ths-add-way {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
    min-height: 72px; padding: 10px 8px; border-radius: var(--ths-radius-tile); cursor: pointer; font-family: inherit;
    border: 1.5px solid rgba(32, 178, 170, 0.6); background: var(--mud-palette-surface);
    color: var(--ths-brand-strong); font-size: var(--ths-fs-md); font-weight: 600; line-height: 1.25; text-align: center;
}
.ths-add-way .mud-icon-root { font-size: var(--ths-icon-lg); }
@media (hover: hover) { .ths-add-way:hover { background: var(--ths-brand-tint); } }

/* ApexCharts follow the theme (2026-11-19): axis text, grid lines and the tooltip from the tokens. The series
   colours come from code (ThsTokens) and read on both grounds. */
.apexcharts-text, .apexcharts-xaxis-label, .apexcharts-yaxis-label { fill: var(--ths-text-2) !important; }
.apexcharts-gridline, .apexcharts-grid line, .apexcharts-xaxis line, .apexcharts-xaxis-tick { stroke: var(--ths-line-soft) !important; }
.apexcharts-tooltip.apexcharts-theme-light { background: var(--ths-surface) !important; color: var(--ths-text) !important; border-color: var(--ths-line) !important; }
.apexcharts-tooltip.apexcharts-theme-light .apexcharts-tooltip-title { background: var(--ths-wash) !important; border-color: var(--ths-line) !important; }

/* A pinned save bar (2026-11-20, owner: Save was at the bottom of a long list and easily forgotten): the
   editor's actions stay in sight at the bottom, above the phone's bottom navigation */
.ths-save-bar {
    position: sticky; bottom: 0; z-index: 5;
    display: flex; justify-content: flex-end; flex-wrap: wrap; gap: var(--ths-space-2);
    padding: var(--ths-space-3) var(--ths-space-4) calc(var(--ths-space-3) + env(safe-area-inset-bottom, 0px));
    margin: var(--ths-space-3) calc(-1 * var(--ths-space-4)) 0;
    background: var(--mud-palette-surface);
    border-top: 1px solid var(--ths-line);
}
@media (max-width: 959.98px) {
    /* Phones: fixed right on top of the bottom navigation, one toolbar with it (owner 2026-11-20: a sticky bar
       left a strip of page between them); .ths-save-bar-space keeps the end of the page clear of it */
    .ths-save-bar:not(.fl-food-bar) {
        position: fixed; left: 0; right: 0; margin: 0; z-index: 1050;
        bottom: calc(60px + env(safe-area-inset-bottom, 0px));
        padding-bottom: var(--ths-space-3);
        border-top: 1px solid var(--mud-palette-divider);
    }
    .ths-save-bar-space { height: 68px; }
}

/* "View as" a persona (Development only, Services/ViewAs): a bar across the top while it's on */
.ths-viewas-bar {
    position: sticky; top: 0; z-index: 1200;
    display: flex; align-items: center; justify-content: center; gap: var(--ths-space-3);
    padding: var(--ths-space-1) var(--ths-space-4);
    background: var(--ths-low-tint); color: var(--ths-text);
    font-size: var(--ths-fs-sm); font-weight: 600;
    border-bottom: 1px solid var(--ths-line);
}
