/**
 * assets/css/hd-style.css
 * Icosmo Human Design - Unified Premium UI v1.6.0
 *
 * DESIGN RULES:
 * - Full dark neutral design. No random green. No hover colour changes.
 * - Off state: dark background, dark border, dark grey text/icon.
 * - On/Active state: white border, white text/icon.
 * - All buttons and inputs unified to the same height (38px).
 * - Panel grid of the Icosmo Matrix Synth (350 px panels, as in Icosmo Katakamuna): birth data,
 *   summary (two panels wide) and player in the first row, mandala and BodyGraph two panels wide
 *   and high, report and genetic code over the full grid width. Four, two or one column(s).
 */

/* --- CORE CONTAINER --- */
/* Base font and colours, panels, panel headings, inputs and buttons come from the shared
   Icosmo interface styles of Icosmo Matrix Core (icosmo-ui.css). */
#icosmo-hd-container {
    max-width: 1456px;                  /* 4 panels of 350 px + 3 gaps of 8 px + padding */
    margin: 20px auto;
    padding: 16px;
    box-sizing: border-box;
    container-type: inline-size;
}

#icosmo-hd-container .module {
    display: flex;
    flex-direction: column;
}

/* --- PANEL GRID: panels of the Icosmo Matrix Synth (350 px) ---
   Columns follow the container width (as in Icosmo Katakamuna): one, two or four.
   Four columns: birth data, summary (two panels wide) and player in the first row,
   mandala and BodyGraph two panels wide and high below. Two columns: the summary
   becomes one panel wide. Report and genetic code span the full grid width. */
#icosmo-hd-container .hd-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-auto-flow: row dense;
    gap: 8px;
    justify-content: center;
}

#icosmo-hd-container .hd-layout > .module {
    margin: 0;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    box-sizing: border-box;
}

#icosmo-hd-container #hd-report-module,
#icosmo-hd-container #hd-genetic-module {
    grid-column: 1 / -1;
}

@container (min-width: 716px) {
    #icosmo-hd-container .hd-layout {
        grid-template-columns: repeat(2, 350px);
        align-items: start;
    }
    #icosmo-hd-container #hd-input-module,
    #icosmo-hd-container #hd-status-module,
    #icosmo-hd-container #hd-audio-player {
        height: 350px;
    }
    #icosmo-hd-container #hd-mandala-module,
    #icosmo-hd-container #hd-visual-module {
        grid-column: span 2;
        grid-row: span 2;
        height: 708px;
    }
}

@container (min-width: 1424px) {
    #icosmo-hd-container .hd-layout {
        grid-template-columns: repeat(4, 350px);
    }
    #icosmo-hd-container #hd-status-module {
        grid-column: span 2;
    }
}

/* --- SUMMARY PANEL: the text scales with the panel width (one or two panels) --- */
#hd-status-module {
    container-type: inline-size;
}

#hd-status-module #hd-summary-results {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    margin-top: 8px;
}

#hd-status-module .hd-summary {
    padding: 4cqi 5cqi;
    font-size: clamp(13px, 2.6cqi, 18px);
    line-height: 1.6;
}

#hd-status-module .hd-summary-type {
    margin: 0 0 0.6em;
    color: #ffffff !important;
    font-size: clamp(17px, 4.6cqi, 32px);
}

#hd-status-module .hd-summary-line {
    margin: 0;
}

#hd-status-module .hd-summary-note {
    margin: 1em 0 0;
    padding-top: 0.8em;
    border-top: 1px solid #333;
    color: #888888;
    font-size: 0.85em;
}

/* --- COMPACT FORM (as in the Icosmo Oracle and Astro Music) --- */
.am-compact-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.am-row-main, .am-row-geo, .am-row-city {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.am-input-group {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

/* Labels and fields as in all Icosmo panels; date and time fields match the shared text fields */
.am-input-group label {
    font-size: var(--font-size-label);
    color: var(--ic-muted, #bdbdbd);
    margin-bottom: 4px;
}

.am-input-group input[type="date"],
.am-input-group input[type="time"] {
    background-color: var(--ic-input-bg, #111111);
    color: var(--ic-input-text, #cccccc);
    border: 1px solid var(--ic-input-border, #777777);
    padding: 4px 6px;
    font-size: var(--font-size-input-text);
    border-radius: 3px;
    width: 100%;
    height: calc(var(--font-size-input-text) + 10px + 2px);
    color-scheme: dark;
}

.date-grp { flex: 2; }
.time-grp { flex: 1.2; }
.tz-grp   { flex: 1; }

.am-bottom-buttons {
    display: flex;
    gap: 8px;
    margin-top: 4px;
}

/* --- FORM BUTTONS: shared Icosmo buttons with the height of the input fields --- */
#hd-geocode-btn,
#hd-now-btn,
#hd-generate-btn {
    height: calc(var(--font-size-input-text) + 10px + 2px);
}

/* Main action: light button */
#icosmo-hd-container #hd-generate-btn {
    background-color: var(--ic-text, #e0e0e0);
    color: #111111;
    border-color: var(--ic-text, #e0e0e0);
}

#icosmo-hd-container #hd-generate-btn:hover {
    background-color: #ffffff;
}

/* ============================================================
   RESONANCE PLAYER: one panel, spectrum and play button above, mixer below
   ============================================================ */

#hd-audio-player {
    gap: 6px;
}

#hd-audio-player > .control-group-heading {
    margin-bottom: 2px;
}

/* Spectrum canvas */
.hd-spectrogram-wrapper {
    flex: none;
    width: 100%;
    height: 90px;
    background: #080808;
    border-radius: 4px;
    border: 1px solid #333;
    overflow: hidden;
}

#hd-audio-visualizer {
    display: block;
    width: 100%;
    height: 100%;
}

/* Player controls: one row */
.hd-player-controls {
    flex: none;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Player buttons keep their own dark design */
#icosmo-hd-container .hd-ctrl-btn {
    background-color: #1a1a1a;
    border: 1px solid #333;
    border-radius: 4px;
    color: #777;
    cursor: pointer;
    width: 26px;
    height: 26px;
    min-height: 0;
    padding: 0;
    font-size: 0.85em;
    font-weight: normal;
    line-height: 1.4;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: color 0.15s ease, border-color 0.15s ease;
}

#icosmo-hd-container .hd-ctrl-btn:hover,
#icosmo-hd-container .hd-ctrl-btn:active {
    background-color: #1a1a1a;
    transform: none;
}

/* Active state — white border + white content */
.hd-ctrl-btn.active {
    border-color: #ffffff;
    color: #ffffff;
}

.hd-player-hint {
    font-size: 0.7em;
    color: #555;
    letter-spacing: 0.5px;
}

/* Mixer: vertical faders as in the Icosmo Matrix Synth and Katakamuna mixers, filling the panel */
.hd-player-mixer {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    justify-content: space-between;
    align-items: stretch;
    gap: 6px;
}

.hd-fader-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1 1 0;
    min-width: 0;
    min-height: 0;
    gap: 2px;
    padding: 5px 2px 4px;
    background-color: #111;
    border: 1px solid #333;
    border-radius: 4px;
    cursor: help;
}

.hd-fader-group label {
    font-size: 0.65em;
    color: #999;
    text-transform: uppercase;
    line-height: 1.1;
    margin: 0;
}

.hd-fader-group input[type="range"].hd-fader {
    writing-mode: vertical-lr;
    direction: rtl;
    -webkit-appearance: none;
    appearance: none;
    flex: 1 1 auto;
    min-height: 0;
    width: 20px;
    height: auto;
    padding: 0;
    margin: 3px auto;
    background: transparent;
    cursor: ns-resize;
}

.hd-fader-group input[type="range"].hd-fader::-webkit-slider-runnable-track {
    width: 7px;
    height: 100%;
    background: #5f5f5f;
    border-radius: 3px;
}

.hd-fader-group input[type="range"].hd-fader::-moz-range-track {
    width: 7px;
    height: 100%;
    background: #5f5f5f;
    border-radius: 3px;
    border: none;
}

.hd-fader-group input[type="range"].hd-fader::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    height: 10px;
    width: 20px;
    margin-left: -6.5px;
    background: #bdbdbd;
    border: 1px solid #333;
    border-radius: 3px;
}

.hd-fader-group input[type="range"].hd-fader::-moz-range-thumb {
    height: 10px;
    width: 20px;
    background: #bdbdbd;
    border: 1px solid #333;
    border-radius: 3px;
}

.hd-fader-value {
    font-size: 0.62em;
    color: #aaa;
    font-variant-numeric: tabular-nums;
}

.hd-fader-key {
    font-size: 0.75em;
    font-weight: bold;
    color: #555;
    min-height: 1.3em;
    white-space: nowrap;
}

.hd-fader-caption {
    font-size: 0.58em;
    color: #666;
    text-align: center;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* ============================================================
   VISUAL MODULES: MANDALA, BODYGRAPH, REPORT, GENETIC CODE
   ============================================================ */

#hd-mandala-module,
#hd-visual-module,
#hd-report-module,
#hd-genetic-module {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.35), 0 8px 20px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

/* Mandala: the wheel fills the panel */
#hd-mandala-wrapper {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #0a0a0a;
    border: 1px solid #222;
    border-radius: 6px;
    padding: 6px;
}

#hd-mandala-wrapper svg {
    display: block;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    filter: drop-shadow(0 0 20px rgba(0,0,0,0.5));
}

/* BodyGraph (full panel height) with the center details beside it */
.hd-visual-flex {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    gap: 8px;
}

#hd-bodygraph-wrapper {
    flex: 0 0 auto;
    aspect-ratio: 310 / 655;
    height: 100%;
    background: #0a0a0a;
    border: 1px solid #222;
    border-radius: 6px;
    box-sizing: border-box;
    padding: 6px;
}

#hd-bodygraph-wrapper svg {
    display: block;
    width: 100%;
    height: 100%;
}

#hd-data-sidebar {
    flex: 1 1 0;
    min-width: 0;
    min-height: 0;
    overflow: auto;
}

#hd-data-sidebar .am-summary-text {
    padding: 14px 16px;
    font-size: 0.85em;
    line-height: 1.5;
}

/* --- SUMMARY & SIDEBAR BLOCKS --- */
.am-summary-text {
    background-color: #181818;
    padding: 25px;
    border-radius: 8px;
    line-height: 1.7;
    font-size: 1.05em;
    border-left: 4px solid #444;
    color: #bbb;
}

.am-summary-text h4 {
    margin-top: 0;
    font-size: 1.3em;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #fff;
}

#hd-data-sidebar .am-sig-label { color: #555 !important; text-transform: uppercase; font-size: 0.8em; }
#hd-data-sidebar .gate-number  { font-weight: bold; }
#hd-data-sidebar .value-text   { color: #ffffff !important; }

.color-swatch {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 2px;
    margin-right: 8px;
}

/* --- MASTER REPORT TABLE --- */
.table-wrapper {
    overflow-x: auto;
    margin-top: 10px;
}

/* The activation table uses the shared Icosmo table design (class "icosmo-table" in icosmo-ui.css) */

.symbol {
    font-family: "Segoe UI Symbol", "Apple Symbols", "Arial Unicode MS", sans-serif;
}

/* --- GENETIC CODE (64 KEYS) --- */
.hd-codon-cell {
    display: flex;
    align-items: center;
    gap: 12px;
}

.hd-hexagram {
    display: inline-block;
    flex: 0 0 auto;
    width: 30px;
    height: 30px;
}

.hd-hexagram svg {
    display: block;
    width: 100%;
    height: 100%;
}

.hd-codon {
    font-family: "SF Mono", Menlo, Consolas, monospace;
    font-weight: bold;
    letter-spacing: 2px;
}

.hd-muted { color: #777; }

.hd-genetic-title {
    margin: 25px 0 10px;
    color: #fff;
    font-size: 0.8em;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.hd-gate-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.hd-gate-chip {
    display: inline-block;
    min-width: 28px;
    padding: 2px 6px;
    border: 1px solid #333;
    border-radius: 4px;
    color: #555;
    font-size: 0.9em;
    text-align: center;
}

.hd-gate-chip.is-active { font-weight: bold; }

.hd-gate-chip sup {
    margin-left: 2px;
    font-size: 0.65em;
    color: #fff;
}

.hd-gate-chip sup.hd-side-d { color: #ef3d31; }

.hd-strand-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}

.hd-strand-label {
    flex: 0 0 90px;
    color: #777;
    font-size: 0.7em;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.hd-strand {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.hd-strand-codon {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 46px;
    padding: 4px 4px 3px;
    background-color: #181818;
    border: 1px solid #2c2c2c;
    border-radius: 4px;
    line-height: 1.3;
}

.hd-strand-codon .symbol { font-size: 1.1em; }
.hd-strand-codon .hd-codon { letter-spacing: 1px; }
.hd-strand-gate { color: #666; font-size: 0.7em; }

.hd-strand-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-top: 15px;
}

.hd-strand-actions .dashicons { vertical-align: middle; }

.hd-strand-status {
    color: #888;
    font-size: 0.85em;
    word-break: break-all;
}

/* Status text */
.status-text {
    color: #666;
    font-size: 0.9em;
}

/* Tuning legend below the activation table */
.hd-legend-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    font-size: 0.85em;
    color: #aaa;
    line-height: 1.6;
}

/* --- RESPONSIVENESS --- */
/* One column: the panels take the height of their content, the BodyGraph stands above its details */
@container (max-width: 715px) {
    #hd-mandala-wrapper { aspect-ratio: 1; }
    #hd-audio-player { min-height: 350px; }
    .hd-visual-flex { flex-direction: column; }
    #hd-bodygraph-wrapper { height: 560px; align-self: center; }
}

@media (max-width: 700px) {
    .am-row-main, .am-row-geo, .am-row-city, .am-bottom-buttons {
        flex-direction: column;
    }
    /* Panels use the full phone width */
    #icosmo-hd-container { padding: 8px; }

    #hd-report-wrapper .am-summary-text {
        font-size: 0.9em;
        line-height: 1.5;
        padding: 12px 14px;
    }

    .hd-strand-row { flex-direction: column; align-items: flex-start; gap: 6px; }
    .hd-strand-label { flex-basis: auto; }

    .hd-legend-grid { grid-template-columns: 1fr; gap: 12px; }

    /* Activation table as cards: planet and gate on top, the three tunings below with their labels */
    #hd-report-wrapper .table-wrapper { overflow: visible; }
    #hd-report-wrapper .hd-activation-table,
    #hd-report-wrapper .hd-activation-table tbody { display: block; width: 100%; }
    #hd-report-wrapper .hd-activation-table thead { display: none; }

    #hd-report-wrapper .hd-activation-table tr {
        display: grid;
        grid-template-columns: 1fr auto;
        column-gap: 12px;
        margin-bottom: 10px;
        border: 1px solid #333;
        border-radius: 8px;
        overflow: hidden;
        background-color: #1e1e1e;
    }
    #hd-report-wrapper .hd-activation-table tr:nth-child(even) { background-color: #242424; }

    #hd-report-wrapper .hd-activation-table td {
        display: block;
        border: none;
        padding: 8px 12px;
        text-align: left;
    }
    #hd-report-wrapper .hd-activation-table td.hd-col-source { padding-top: 12px; }
    #hd-report-wrapper .hd-activation-table td.hd-col-gate { padding-top: 12px; text-align: right; }
    #hd-report-wrapper .hd-activation-table td.hd-col-gate > div { align-items: flex-end; }

    #hd-report-wrapper .hd-activation-table td.hd-col-detail {
        grid-column: 1 / -1;
        display: grid;
        grid-template-columns: 96px 1fr;
        column-gap: 10px;
        border-top: 1px solid #2c2c2c;
    }
    #hd-report-wrapper .hd-activation-table td.hd-col-detail::before {
        content: attr(data-label);
        grid-row: 1 / span 2;
        color: #777;
        font-size: 0.7em;
        font-weight: bold;
        text-transform: uppercase;
        letter-spacing: 1px;
        padding-top: 3px;
    }
}
