/* =====================================================================
 * Catfish — Waterline aesthetic
 * Single source of truth for design tokens, type, and shared classes.
 * Loaded by Catfish.Web + Catfish MAUI via _content/Catfish.Shared/app.css
 * ===================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght,SOFT@9..144,400..700,50..100&family=IBM+Plex+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500&display=swap');

:root {
    /* ---- Palette: Waterline ------------------------------------------ */
    --c-inkwell:        #0d1411;   /* deepest — page background */
    --c-deep-water:     #141e1a;   /* card / elevated surface */
    --c-tidepool:       #1b2a25;   /* second-layer surface */
    --c-current:        #243630;   /* tertiary / hover */
    --c-divider:        rgba(255, 255, 255, 0.06);

    --c-mist:           #e8ebe6;   /* primary text on dark */
    --c-silver-mist:    #9aa49c;   /* secondary text */
    --c-shadow-text:    #5c6660;   /* tertiary / meta */

    /* Life — algae + copper is the brand axis */
    --c-algae:          #5fb573;   /* positive / growth / primary accent */
    --c-algae-deep:     #3d8a54;
    --c-moss:           #a0c47a;   /* secondary positive */
    --c-copper:         #c87847;   /* warm accent — feeding, action */
    --c-copper-soft:    #e0a175;

    /* Water */
    --c-cerulean:       #4aa3c7;   /* cool / informational */
    --c-cerulean-deep:  #2a7595;

    /* Warnings */
    --c-amber:          #e8ba4a;   /* caution — not red-shifted yellow */
    --c-koi:            #d94d2a;   /* critical */
    --c-rust:           #8a2818;   /* dangerous / hypoxic */

    /* ---- Semantic water-quality (map old helpers onto palette) ------- */
    --c-status-excellent:       var(--c-cerulean);
    --c-status-optimal:         var(--c-algae);
    --c-status-caution:         var(--c-amber);
    --c-status-critical:        var(--c-koi);
    --c-status-hypoxic:         var(--c-rust);
    --c-status-supersaturated:  #7a5ba8;

    /* ---- Tank heat (capacity) ---------------------------------------- */
    --c-heat-low:   var(--c-algae-deep);
    --c-heat-mid:   var(--c-amber);
    --c-heat-high:  var(--c-koi);

    --c-capacity-low:    #1f3a2c;
    --c-capacity-medium: #4a3420;
    --c-capacity-high:   #4a1e16;

    /* ---- Type --------------------------------------------------------- */
    --f-display: 'Fraunces', 'Iowan Old Style', 'Palatino', Georgia, serif;
    --f-ui:      'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    --f-mono:    'IBM Plex Mono', ui-monospace, 'SF Mono', 'Cascadia Mono', 'Roboto Mono', monospace;

    /* ---- Radii + shadow + spacing ------------------------------------ */
    --r-sm: 4px;
    --r-md: 8px;
    --r-lg: 14px;
    --r-pill: 999px;

    --shadow-card: 0 1px 0 rgba(255, 255, 255, .02) inset,
                   0 1px 3px rgba(0, 0, 0, .4),
                   0 6px 20px rgba(0, 0, 0, .35);
    --shadow-lift: 0 2px 4px rgba(0, 0, 0, .5),
                   0 12px 30px rgba(0, 0, 0, .45);

    /* ---- Radzen overrides -------------------------------------------- */
    --rz-primary:               var(--c-algae);
    --rz-primary-lighter:       var(--c-moss);
    --rz-primary-darker:        var(--c-algae-deep);
    --rz-secondary:             var(--c-copper);
    --rz-info:                  var(--c-cerulean);
    --rz-success:               var(--c-algae);
    --rz-warning:               var(--c-amber);
    --rz-danger:                var(--c-koi);

    --rz-base-background-color: var(--c-inkwell);
    --rz-base:                  var(--c-mist);
    --rz-body-background-color: var(--c-inkwell);
    --rz-body-color:            var(--c-mist);
    --rz-text-color:            var(--c-mist);
    --rz-text-secondary-color:  var(--c-silver-mist);
    --rz-border-color:          var(--c-divider);

    --rz-card-background-color: var(--c-deep-water);
    --rz-card-color:            var(--c-mist);
    --rz-card-box-shadow:       var(--shadow-card);
    --rz-panel-background-color: var(--c-deep-water);
}

/* Optional: light variant. Opt in by adding `data-theme="light"` to <html>. */
html[data-theme="light"] {
    --c-inkwell:      #f5f3ec;
    --c-deep-water:   #ffffff;
    --c-tidepool:     #edeae0;
    --c-current:      #e1ddcf;
    --c-mist:         #0d1411;
    --c-silver-mist:  #4a524d;
    --c-shadow-text:  #6c746e;
    --c-divider:      rgba(0, 0, 0, 0.08);
    --shadow-card:    0 1px 2px rgba(0, 0, 0, .05), 0 2px 8px rgba(0, 0, 0, .06);
}

/* ---------------------------------------------------------------------
 * Baseline
 * ------------------------------------------------------------------- */

html, body {
    background: var(--c-inkwell);
    color: var(--c-mist);
    font-family: var(--f-ui);
    font-feature-settings: "ss01", "cv05"; /* Plex stylistic alternates */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* Faint organic noise on the page bg so it doesn't feel flat digital. */
body {
    background-image:
        radial-gradient(1200px 600px at 80% -20%, rgba(95, 181, 115, 0.05), transparent 60%),
        radial-gradient(900px 400px at -10% 120%, rgba(74, 163, 199, 0.05), transparent 60%),
        url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='140'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' seed='4'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 0.03 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
    background-attachment: fixed;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--f-display);
    font-weight: 500;
    letter-spacing: -0.015em;
    color: var(--c-mist);
    margin-top: 0;
}

h1 { font-size: clamp(2rem, 4vw, 3rem); line-height: 1.05; letter-spacing: -0.025em; }
h2 { font-size: clamp(1.5rem, 3vw, 2.25rem); line-height: 1.1; }
h3 { font-size: clamp(1.25rem, 2.5vw, 1.75rem); line-height: 1.2; font-weight: 500; }
h4 { font-size: 1.125rem; line-height: 1.3; font-weight: 500; font-family: var(--f-ui); letter-spacing: -0.005em; }
h5, h6 { font-family: var(--f-ui); font-weight: 600; letter-spacing: 0; }

a, .btn-link { color: var(--c-cerulean); text-decoration: none; }
a:hover, .btn-link:hover { color: var(--c-moss); text-decoration: underline; }

.btn-primary {
    color: var(--c-inkwell);
    background-color: var(--c-algae);
    border-color: var(--c-algae-deep);
    font-family: var(--f-ui);
    font-weight: 500;
}
.btn-primary:hover { background-color: var(--c-moss); border-color: var(--c-algae); }

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus,
.form-control:focus, .form-check-input:focus {
    box-shadow: 0 0 0 2px var(--c-inkwell), 0 0 0 4px var(--c-algae);
}

.content { padding-top: 1.5rem; }
h1:focus { outline: none; }

.valid.modified:not([type=checkbox]) { outline: 1px solid var(--c-algae); }
.invalid { outline: 1px solid var(--c-koi); }
.validation-message { color: var(--c-koi); }

.blazor-error-boundary {
    background: var(--c-rust);
    padding: 1rem 1rem 1rem 3.7rem;
    color: var(--c-mist);
    font-family: var(--f-ui);
}
.blazor-error-boundary::after { content: "An error has occurred." }

/* ---------------------------------------------------------------------
 * Typography utilities (use on any page/component)
 * ------------------------------------------------------------------- */

.display {
    font-family: var(--f-display);
    font-weight: 500;
    letter-spacing: -0.02em;
    font-variation-settings: "opsz" 48, "SOFT" 50;
}
.display-lg {
    font-family: var(--f-display);
    font-weight: 400;
    font-size: clamp(2.5rem, 6vw, 4rem);
    line-height: 1;
    letter-spacing: -0.03em;
    font-variation-settings: "opsz" 144, "SOFT" 50;
}

.section-label {
    display: block;
    font-family: var(--f-ui);
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--c-silver-mist);
}

.eyebrow {
    font-family: var(--f-mono);
    font-size: 0.6875rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--c-shadow-text);
}

.metric-number {
    font-family: var(--f-display);
    font-weight: 400;
    font-size: clamp(2.25rem, 4vw, 3rem);
    line-height: 1;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum", "lnum";
    color: var(--c-mist);
}
.metric-unit {
    font-family: var(--f-ui);
    font-size: 0.75em;
    font-weight: 400;
    color: var(--c-silver-mist);
    margin-left: 0.25em;
}
.metric-delta {
    font-family: var(--f-mono);
    font-size: 0.75rem;
    letter-spacing: 0.04em;
}
.metric-delta.up   { color: var(--c-algae); }
.metric-delta.down { color: var(--c-koi); }

.tabular-nums {
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum", "lnum";
}

.text-muted { color: var(--c-silver-mist) !important; }
.text-meta  { color: var(--c-shadow-text); }
.text-right { text-align: right; }

/* Section divider — not a full hr; a tick on the left */
.tick-divider {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 1.5rem 0 0.75rem;
}
.tick-divider::before {
    content: "";
    width: 2px;
    height: 1rem;
    background: var(--c-algae);
    border-radius: 1px;
}

/* ---------------------------------------------------------------------
 * Surfaces — reusable "panel" primitives
 * ------------------------------------------------------------------- */

.panel {
    background: var(--c-deep-water);
    border: 1px solid var(--c-divider);
    border-radius: var(--r-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow-card);
}
.panel-tidepool {
    background: var(--c-tidepool);
}
.panel-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}
.panel-title {
    font-family: var(--f-ui);
    font-weight: 600;
    font-size: 1rem;
    color: var(--c-mist);
    margin: 0;
}

/* KPI card — use inside a RadzenCard or standalone */
.kpi-card {
    background: var(--c-deep-water);
    border: 1px solid var(--c-divider);
    border-radius: var(--r-lg);
    padding: 1.25rem 1.25rem 1rem;
    box-shadow: var(--shadow-card);
    position: relative;
    overflow: hidden;
}
.kpi-card::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--c-algae);
}
.kpi-card.accent-copper::before  { background: var(--c-copper); }
.kpi-card.accent-cerulean::before { background: var(--c-cerulean); }
.kpi-card.accent-amber::before   { background: var(--c-amber); }
.kpi-card.accent-koi::before     { background: var(--c-koi); }

.kpi-label {
    font-family: var(--f-ui);
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--c-silver-mist);
    margin-bottom: 0.5rem;
}
.kpi-value {
    font-family: var(--f-display);
    font-size: clamp(2rem, 4vw, 2.75rem);
    line-height: 1;
    font-weight: 400;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
    color: var(--c-mist);
}
.kpi-meta {
    margin-top: 0.5rem;
    font-family: var(--f-mono);
    font-size: 0.75rem;
    color: var(--c-shadow-text);
}

/* ---------------------------------------------------------------------
 * Tank cards
 * ------------------------------------------------------------------- */

.tank-card {
    background: var(--c-tidepool);
    color: var(--c-mist);
    padding: 0.875rem 0.875rem 0.875rem 1rem;
    border-radius: var(--r-md);
    border: 1px solid var(--c-divider);
    cursor: pointer;
    transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
    position: relative;
    min-height: 118px;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    overflow: hidden;
}
.tank-card::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: rgba(255, 255, 255, 0.08);
}
.tank-card[data-status="optimal"]::before        { background: var(--c-algae); }
.tank-card[data-status="excellent"]::before      { background: var(--c-cerulean); }
.tank-card[data-status="caution"]::before        { background: var(--c-amber); }
.tank-card[data-status="critical"]::before       { background: var(--c-koi); }
.tank-card[data-status="hypoxic"]::before        { background: var(--c-rust); }
.tank-card[data-status="supersaturated"]::before { background: var(--c-status-supersaturated); }
.tank-card[data-status="empty"]::before          { background: var(--c-shadow-text); opacity: 0.35; }
.tank-card:hover {
    transform: translateY(-2px);
    border-color: rgba(95, 181, 115, 0.4);
    box-shadow: var(--shadow-lift);
}
.tank-card:active { transform: translateY(0); cursor: grabbing; }
.tank-card.drag-over {
    border: 1px dashed var(--c-algae);
    background: var(--c-current);
}
.tank-card.shake { animation: shake 0.3s; }

.tank-header {
    font-family: var(--f-ui);
    font-size: 0.875rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--c-mist);
    margin: 0;
}
.tank-body    { font-size: 0.8125rem; color: var(--c-silver-mist); }
.tank-type    {
    font-family: var(--f-mono);
    font-size: 0.6875rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--c-shadow-text);
    margin: 0;
}
.tank-label   { font-weight: 600; }
.tank-biomass { font-size: 0.6875rem; font-family: var(--f-mono); }

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25%      { transform: translateX(-5px); }
    50%      { transform: translateX(5px); }
    75%      { transform: translateX(-5px); }
}

.tank-board {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
}
.tank-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
}
.tank-row {
    display: flex;
    justify-content: space-between;
    padding: 6px;
    border-radius: var(--r-sm);
    margin-bottom: 4px;
    color: var(--c-mist);
}

/* Capacity bar inside tank card */
.capacity-bar {
    height: 4px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 2px;
    overflow: hidden;
    margin-top: auto;
}
.capacity-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--c-algae-deep), var(--c-algae));
    border-radius: 2px;
    transition: width 0.4s ease;
}

/* Full-card capacity shading (used in some views) */
.capacity-low    { background: var(--c-capacity-low); }
.capacity-medium { background: var(--c-capacity-medium); }
.capacity-high   { background: var(--c-capacity-high); }

/* Badges */
.badge {
    padding: 3px 8px;
    border-radius: var(--r-pill);
    color: var(--c-mist);
    font-family: var(--f-mono);
    font-size: 0.6875rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}
.badge.green  { background: var(--c-algae-deep); }
.badge.orange { background: var(--c-copper); }
.badge.red    { background: var(--c-koi); }

/* Heatmap grid */
.heatmap-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
    gap: 6px;
}
.heatmap-cell {
    padding: 8px;
    border-radius: var(--r-sm);
    color: var(--c-mist);
    text-align: center;
    font-size: 0.75rem;
    cursor: pointer;
    transition: transform 0.15s ease;
    font-variant-numeric: tabular-nums;
}
.heatmap-cell:hover { transform: scale(1.05); }
.heat-low  { background: var(--c-heat-low); }
.heat-mid  { background: var(--c-heat-mid); color: var(--c-inkwell); }
.heat-high { background: var(--c-heat-high); }

/* ---------------------------------------------------------------------
 * Water-quality status (applied to Radzen columns in TankDashboard)
 * NOTE: colour-only signalling is an accessibility gap; pair with an
 * icon + pattern when we redesign the water-quality strip.
 * ------------------------------------------------------------------- */

.excellent      { background: var(--c-status-excellent)      !important; color: var(--c-inkwell) !important; }
.optimal        { background: var(--c-status-optimal)        !important; color: var(--c-inkwell) !important; }
.caution        { background: var(--c-status-caution)        !important; color: var(--c-inkwell) !important; }
.critical       { background: var(--c-status-critical)       !important; color: var(--c-mist) !important; }
.hypoxic        { background: var(--c-status-hypoxic)        !important; color: var(--c-mist) !important; }
.supersaturated { background: var(--c-status-supersaturated) !important; color: var(--c-mist) !important; }

/* ---------------------------------------------------------------------
 * Radzen component nudges — keep alignment with Waterline
 * ------------------------------------------------------------------- */

.rz-button {
    font-family: var(--f-ui);
    font-weight: 500;
    letter-spacing: 0.01em;
}

.rz-card {
    background: var(--c-deep-water) !important;
    border: 1px solid var(--c-divider) !important;
    border-radius: var(--r-lg) !important;
    box-shadow: var(--shadow-card) !important;
    color: var(--c-mist) !important;
}

.rz-alert {
    border-radius: var(--r-md) !important;
    font-family: var(--f-ui) !important;
}

.rz-datagrid, .rz-data-grid {
    background: var(--c-deep-water) !important;
    color: var(--c-mist) !important;
    border-radius: var(--r-lg);
    overflow: hidden;
}

.rz-chart {
    font-family: var(--f-ui) !important;
}

/* ---------------------------------------------------------------------
 * Touch-friendly tap targets on mobile
 * ------------------------------------------------------------------- */

@media (max-width: 640.98px) {
    .rz-button {
        min-height: 44px;
        padding-inline: 1rem;
    }

    .rz-button.rz-button-sm,
    .rz-button-small {
        min-height: 40px;
    }

    /* Raise icon-only action buttons to 44 px square */
    .rz-button.rz-button-icon-only {
        min-width: 44px;
        min-height: 44px;
    }

    /* Page header hairline bottom-padding so content isn't tight against
     * the fixed bottom tab bar on very short phones. */
    .farm-overview,
    .content article,
    article.content {
        padding-bottom: 1rem;
    }
}

/* Form floating label fixes */
.darker-border-checkbox.form-check-input { border-color: var(--c-silver-mist); }

.form-floating > .form-control-plaintext::placeholder,
.form-floating > .form-control::placeholder {
    color: var(--c-silver-mist);
    text-align: end;
}
.form-floating > .form-control-plaintext:focus::placeholder,
.form-floating > .form-control:focus::placeholder {
    text-align: start;
}
