/* ========================================================================= */
/* MODULE: CSS DESIGN SYSTEM & THEMING                                       */
/* ========================================================================= */
:root {
    --bg-base: #fff0f5;
    --card-bg: rgba(255, 255, 255, 0.7);
    --text-main: #4a154b;
    --text-muted: #8b5e8c;
    --accent: #ff4d85;
    --accent-glow: rgba(255, 77, 133, 0.4);
    --surface-border: rgba(255, 77, 133, 0.2);
    --nav-bg: rgba(255, 255, 255, 0.9);
    /* Opaque composite of --card-bg over --bg-base, for SVG rings and tooltips
       where a translucent fill would let the line show through. */
    --card-bg-solid: #fffafc;
}

[data-theme="dark"] {
    --bg-base: #110810;
    --card-bg: rgba(30, 15, 28, 0.7);
    --text-main: #ffe6f0;
    --text-muted: #b385a6;
    --accent: #ff2a6d;
    --accent-glow: rgba(255, 42, 109, 0.5);
    --surface-border: rgba(255, 42, 109, 0.3);
    --nav-bg: rgba(17, 8, 16, 0.9);
    --card-bg-solid: #1a0d18;
}

body {
    background: var(--bg-base);
    color: var(--text-main);
    font-family: 'Outfit', sans-serif;
    margin: 0;
    padding: 0;
    transition: background-color 0.4s ease, color 0.4s ease;
    overflow-x: hidden;
    -webkit-tap-highlight-color: transparent;
}

h1, h2, h3 { margin: 0; font-weight: 600; }

.glam-title {
    background: linear-gradient(135deg, var(--accent), #ff9eb5);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-size: 2rem;
    font-weight: 700;
}

.glass {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--surface-border);
    border-radius: 24px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.accent-text { color: var(--accent); }

/* ========================================================================= */
/* MODULE: CSS LAYOUTS & COMPONENTS                                          */
/* ========================================================================= */
.header {
    padding: 20px;
    padding-top: 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Silhouettes */
.silhouettes-container {
    display: flex;
    justify-content: space-around;
    align-items: flex-end;
    height: 280px;
    padding: 20px 0;
    position: relative;
    margin: 0 20px;
}
.silhouette-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 45%;
}
.silhouette-svg {
    height: 200px;
    fill: var(--text-main);
    /* The figure is animated by regenerating its `d` (see drawSilhouette in
       src/ui.js); a transform transition no longer applies. */
    filter: drop-shadow(0 0 10px var(--accent-glow));
    transform-origin: bottom center;
}
.future-body .silhouette-svg {
    fill: url(#pink-glow);
}
.body-label {
    margin-bottom: 10px;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--accent);
    text-align: center;
}
.body-weight {
    margin-top: 10px;
    font-size: 1.2rem;
    font-weight: 700;
}

/* Inputs & Buttons */
.flirty-input {
    background: transparent;
    border: 2px solid var(--surface-border);
    border-radius: 16px;
    color: var(--text-main);
    font-family: inherit;
    font-size: 1.5rem;
    padding: 15px;
    text-align: center;
    width: 130px;
    outline: none;
    transition: border-color 0.3s, box-shadow 0.3s;
}
.flirty-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 15px var(--accent-glow);
}
.flirty-btn {
    background: linear-gradient(135deg, var(--accent), #ff6b9a);
    color: white;
    border: none;
    border-radius: 99px;
    padding: 16px 32px;
    font-size: 1.2rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 20px var(--accent-glow);
    transition: transform 0.2s, box-shadow 0.2s;
}
.flirty-btn:active {
    transform: scale(0.95);
    box-shadow: 0 2px 10px var(--accent-glow);
}
.secondary-btn {
    background: transparent;
    border: 1px solid var(--accent);
    color: var(--accent);
    padding: 8px 16px;
    border-radius: 99px;
    font-size: 0.9rem;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.3s;
}
.secondary-btn:active { background: var(--accent-glow); }

/* Projection Horizon Cards */
.horizons {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding: 10px 20px;
    scrollbar-width: none;
}
.horizons::-webkit-scrollbar { display: none; }
.horizon-card {
    min-width: 80px;
    padding: 12px;
    border-radius: 16px;
    text-align: center;
    cursor: pointer;
    border: 1px solid var(--surface-border);
    transition: all 0.3s;
    flex-shrink: 0;
    font-weight: 500;
}
.horizon-card.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
    box-shadow: 0 4px 15px var(--accent-glow);
}

/* Screens */
.screen {
    display: none;
    padding-bottom: 120px;
    animation: fadeIn 0.4s ease;
}
.screen.active { display: block; }

/* The setup screen needs flex centering, but it must still be hideable.
   This lives in CSS (not an inline style) so switchScreen()'s class toggle
   actually controls visibility -- an inline `display` would always win. */
.screen.screen--center { padding: 0; }
.screen.screen--center.active {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Nav */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--nav-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    justify-content: space-around;
    padding: 15px 20px;
    border-top: 1px solid var(--surface-border);
    padding-bottom: env(safe-area-inset-bottom, 20px);
    z-index: 100;
}
.nav-item {
    color: var(--text-muted);
    text-decoration: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    transition: color 0.3s;
    cursor: pointer;
}
.nav-item.active {
    color: var(--accent);
    filter: drop-shadow(0 0 5px var(--accent-glow));
}

/* Praise Toast & Animations */
.praise-toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.5);
    background: rgba(30, 15, 28, 0.9);
    backdrop-filter: blur(15px);
    border: 1px solid var(--accent);
    padding: 25px 40px;
    border-radius: 40px;
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--accent);
    box-shadow: 0 10px 50px var(--accent-glow);
    opacity: 0;
    pointer-events: none;
    transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 1000;
    text-align: center;
    width: 80%;
    max-width: 400px;
    line-height: 1.3;
}
[data-theme="light"] .praise-toast { background: rgba(255, 255, 255, 0.95); }
.praise-toast.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}
.sparkle {
    position: absolute;
    pointer-events: none;
    animation: floatUp 1.5s ease-out forwards;
    font-size: 1.5rem;
    z-index: 999;
}
@keyframes floatUp {
    0% { opacity: 1; transform: translateY(0) scale(1) rotate(0deg); }
    100% { opacity: 0; transform: translateY(-100px) scale(1.5) rotate(45deg); }
}

/* --- Entry rows (with edit/delete) ------------------------------------- */
.entry-row {
    padding: 14px 18px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
}
.entry-time { color: var(--text-muted); font-weight: 500; }
.entry-kcal { font-size: 1.1rem; margin-left: auto; }
.entry-btn {
    background: transparent;
    border: 1px solid var(--surface-border);
    color: var(--text-muted);
    border-radius: 999px;
    padding: 5px 12px;
    font-family: inherit;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s ease;
}
.entry-btn:hover, .entry-btn:focus-visible {
    color: var(--accent);
    border-color: var(--accent);
}

/* --- No-data note under the projection -------------------------------- */
.projection-note {
    display: none;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--surface-border);
    font-size: 0.8rem;
    line-height: 1.45;
    color: var(--text-muted);
    text-align: center;
}

/* --- Body profile grid -------------------------------------------------- */
.profile-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 12px 14px;
    align-items: center;
}
.profile-grid label {
    font-weight: 500;
    font-size: 0.95rem;
}
.profile-field {
    width: 100%;
    box-sizing: border-box;
    padding: 10px 14px;
    font-size: 1rem;
}
/* Native select needs the chevron drawn in, and it must recolor per theme. */
select.flirty-input {
    appearance: none;
    -webkit-appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, var(--accent) 50%),
                      linear-gradient(135deg, var(--accent) 50%, transparent 50%);
    background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
    padding-right: 34px;
    cursor: pointer;
}
select.flirty-input option {
    background: var(--bg-base);
    color: var(--text-main);
}
.tdee-readout {
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid var(--surface-border);
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.5;
}
.tdee-readout strong { color: var(--accent); }

/* --- Weight chart -------------------------------------------------------
   One series hue. --accent differs per theme, so this is a selected pair
   rather than an automatic flip, and it clears 3:1 on the composited card
   surface (#fffafc light / #1a0d18 dark) in both modes. */
.chart-card { position: relative; }
.weight-chart { display: block; overflow: visible; }

.ch-line {
    fill: none;
    stroke: var(--accent);
    stroke-width: 2;
    stroke-linejoin: round;
    stroke-linecap: round;
    filter: drop-shadow(0 0 6px var(--accent-glow));
}
.ch-proj {
    fill: none;
    stroke: var(--accent);
    stroke-width: 2;
    stroke-dasharray: 4 5;
    stroke-linecap: round;
    opacity: 0.5;
}
.ch-area { fill: url(#pink-glow); opacity: 0.10; stroke: none; }

/* 2px ring in the surface colour so dots stay legible over the line. */
.ch-dot { fill: var(--accent); stroke: var(--card-bg-solid); stroke-width: 2; }

/* Gridlines are hairline and SOLID; the dashed rule is the goal reference. */
.ch-grid { stroke: var(--surface-border); stroke-width: 1; }
.ch-goal { stroke: var(--text-muted); stroke-width: 1; stroke-dasharray: 2 4; opacity: 0.8; }

/* Text wears text tokens, never the series colour. */
.ch-axis, .ch-goal-label, .ch-proj-label { fill: var(--text-muted); font-size: 9px; }
.ch-end { fill: var(--text-main); font-size: 11px; font-weight: 600; }
.ch-proj-label { font-size: 10px; }

.ch-cross { stroke: var(--text-muted); stroke-width: 1; opacity: 0.55; pointer-events: none; }
.ch-hit { fill: transparent; cursor: crosshair; }

.chart-tooltip {
    position: absolute;
    pointer-events: none;
    transform: translate(-50%, -115%);
    background: var(--card-bg-solid);
    border: 1px solid var(--surface-border);
    border-radius: 10px;
    padding: 6px 10px;
    font-size: 0.8rem;
    white-space: nowrap;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
    display: none;
    z-index: 5;
}
/* Value leads, label follows -- the reader has the date and wants the number. */
.chart-tooltip .tt-value { font-weight: 700; color: var(--accent); }
.chart-tooltip .tt-label { color: var(--text-muted); margin-left: 6px; }

.chart-empty { color: var(--text-muted); text-align: center; margin: 24px 0; font-size: 0.9rem; }

.chart-table-toggle {
    display: block;
    margin: 14px auto 0;
    background: none;
    border: none;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.8rem;
    text-decoration: underline;
    cursor: pointer;
}
.chart-table { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 0.85rem; }
.chart-table th, .chart-table td {
    text-align: left;
    padding: 6px 4px;
    border-bottom: 1px solid var(--surface-border);
}
.chart-table th { color: var(--text-muted); font-weight: 500; }

/* Sub-label under the projected figure's title. */
.body-sub {
    margin-top: -6px;
    margin-bottom: 8px;
    font-size: 0.7rem;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    text-transform: uppercase;
}

/* --- Day switcher ------------------------------------------------------
   The log card addresses one day at a time. The forward arrow disables at
   today rather than disappearing, so the control does not reflow as you
   walk back and forth through the week. */
.day-switcher {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 14px;
}
.day-switcher-label { flex: 1; min-width: 0; }
.day-arrow {
    background: transparent;
    border: 1px solid var(--surface-border);
    color: var(--text-main);
    border-radius: 50%;
    width: 38px;
    height: 38px;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    flex: 0 0 auto;
    transition: background-color 0.2s ease, opacity 0.2s ease;
}
.day-arrow:hover:not([disabled]) { background: var(--surface-border); }
.day-arrow[disabled] { opacity: 0.25; cursor: default; }
.day-back-to-today {
    background: transparent;
    border: 0;
    color: var(--accent);
    font: inherit;
    font-size: 0.78rem;
    cursor: pointer;
    padding: 2px 0 0;
    text-decoration: underline;
}
.entry-label {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-left: 8px;
}
.history-row { cursor: pointer; }
.history-row:hover { border-color: var(--accent); }
