/**
 * assets/css/kabbalah-style.css
 * Icosmo Kabbalah - Interface v1.1.0
 *
 * UPDATED v1.1.0:
 * - Tree of Life Track panel (player of Icosmo Astro Music) with the shared progress bar and the visualizer.
 * - The buttons of the next step are light (class kb-next); all others keep the dark design.
 *
 * DESIGN RULES (as in Icosmo Human Design):
 * - Full dark neutral design; colours only from the Icosmo Matrix (letters, Sephiroth, keys).
 * - Panel grid of the Icosmo Matrix Synth (350 px panels): birth data, summary, birth cards and the
 *   Tree of Life Track in the first row, the Tree of Life and the card of the selection two panels wide and high,
 *   the tables over the full grid width. Four, two or one column(s).
 * - Base font and colours, panels, panel headings, inputs, buttons and tables come from icosmo-ui.css.
 */

/* --- CORE CONTAINER --- */
#icosmo-kabbalah-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-kabbalah-container .module {
    display: flex;
    flex-direction: column;
}

/* --- EXPORT BAR: PDF export at the top right above the panels --- */
.kb-toolbar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 8px;
}

#icosmo-kabbalah-container .kb-export-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: none;
    border: none;
    padding: 4px 0;
    min-height: 0;
    color: var(--ic-text, #e0e0e0);
    font-size: 0.9em;
    cursor: pointer;
}

#icosmo-kabbalah-container .kb-export-btn .dashicons {
    font-size: 24px;
    width: 24px;
    height: 24px;
}

#icosmo-kabbalah-container .kb-export-btn:hover .kb-export-label { text-decoration: underline; }
#icosmo-kabbalah-container .kb-export-btn.is-busy { opacity: 0.5; cursor: wait; }

/* --- PANEL GRID --- */
#icosmo-kabbalah-container .kb-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-auto-flow: row dense;
    gap: 8px;
    justify-content: center;
}

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

#icosmo-kabbalah-container #kb-paths-module,
#icosmo-kabbalah-container #kb-sephiroth-module {
    grid-column: 1 / -1;
}

@container (min-width: 716px) {
    #icosmo-kabbalah-container .kb-layout {
        grid-template-columns: repeat(2, 350px);
        align-items: start;
    }
    #icosmo-kabbalah-container #kb-input-module,
    #icosmo-kabbalah-container #kb-summary-module,
    #icosmo-kabbalah-container #kb-cards-module,
    #icosmo-kabbalah-container #kb-track-module {
        height: 350px;
    }
    #icosmo-kabbalah-container #kb-tree-module,
    #icosmo-kabbalah-container #kb-detail-module {
        grid-column: span 2;
        grid-row: span 2;
        height: 708px;
    }
}

@container (min-width: 1424px) {
    #icosmo-kabbalah-container .kb-layout {
        grid-template-columns: repeat(4, 350px);
    }
}

/* --- COMPACT FORM (as in Icosmo Human Design) --- */
.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;
}

.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; }

.kb-geocode-status {
    font-size: 0.8em;
    color: #888888;
    margin-top: 2px;
    min-height: 1.2em;
}

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

#kb-geocode-btn,
#kb-now-btn,
#kb-generate-btn {
    height: calc(var(--font-size-input-text) + 10px + 2px);
}

#kb-now-btn,
#kb-generate-btn {
    flex: 1;
}

/* Next step: light button (Show my Tree, then Create Track, then Play, Reel and Download / Buy) */
#icosmo-kabbalah-container button.kb-next {
    background-color: var(--ic-text, #e0e0e0);
    color: #111111;
    border-color: var(--ic-text, #e0e0e0);
}

#icosmo-kabbalah-container button.kb-next:hover:not(:disabled) {
    background-color: #ffffff;
}

/* --- SUMMARY PANEL WITH STATUS AND PROGRESS BAR --- */
#kb-summary-module {
    container-type: inline-size;
}

.kb-status {
    color: var(--ic-muted, #bdbdbd);
    font-size: 0.9em;
    font-style: italic;
    text-align: center;
}

#kb-summary-results {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
}

.kb-summary {
    padding: 2cqi 3cqi;
    font-size: clamp(13px, 2.2cqi, 16px);
    line-height: 1.55;
    color: #cccccc;
}

.kb-summary p { margin: 0 0 0.7em; }
.kb-summary strong { color: #ffffff; }

.kb-summary-small {
    font-size: 0.85em;
    color: #999999;
}

.kb-pillars {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 0 0 0.8em;
}

.kb-pillar {
    display: grid;
    grid-template-columns: 70px 1fr 44px;
    align-items: center;
    gap: 8px;
    font-size: 0.85em;
}

.kb-pillar-name { color: #999999; }
.kb-pillar-value { color: #cccccc; text-align: right; }

.kb-pillar-track {
    height: 8px;
    background-color: #222222;
    border-radius: 4px;
    overflow: hidden;
}

.kb-pillar-fill {
    display: block;
    height: 100%;
    background-color: #bbbbbb;
}

/* --- TREE OF LIFE TRACK (player of Icosmo Astro Music) --- */
.kb-track-controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
    min-height: 0;
}

.kb-track-status {
    font-size: 0.9em;
    color: #cccccc;
    text-align: center;
    min-height: 1.4em;
    font-style: italic;
}

/* The progress bar is the Icosmo progress bar of Icosmo Matrix Core (icosmo-ui.css) */

/* Two rows: coloured waveform overview on top, key spectrum below */
#kb-visualizer-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: #0a0a0a;
    border-radius: 8px;
    padding: 6px;
    border: 1px solid #333333;
    min-height: 120px;
}

#kb-waveform-canvas,
#kb-spectrum-canvas {
    display: block;
    flex: 1 1 0;
    width: 100%;
    height: 0;               /* the canvas resolution must not set the row height */
    min-height: 0;
    border-radius: 4px;
}

.kb-track-actions {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    gap: 8px;
}

.kb-track-actions > span {
    display: flex;
}

.kb-track-actions > span > button {
    flex: 1;
}

#icosmo-kabbalah-container .kb-track-actions button {
    height: calc(var(--font-size-input-text) + 10px + 2px);
    display: flex;
    align-items: center;
    justify-content: center;
}

#icosmo-kabbalah-container .kb-track-actions button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

#kb-track-buy-wrap:has(#kb-track-buy-btn:disabled) {
    cursor: not-allowed;
}

#kb-track-buy-wrap #kb-track-buy-btn:disabled {
    pointer-events: none;
}

/* --- BIRTH CARDS --- */
#kb-birth-cards {
    flex: 1 1 auto;
    min-height: 0;
}

.kb-birth-cards {
    display: flex;
    justify-content: center;
    gap: 10px;
    height: 100%;
}

#icosmo-kabbalah-container .kb-card-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    height: auto;
    max-height: 100%;
    padding: 6px;
    background-color: #0d0d0d;
    border: 1px solid #262626;
    border-radius: 8px;
    color: #bbbbbb;
    font-size: 0.8em;
    cursor: pointer;
}

#icosmo-kabbalah-container .kb-card-btn:hover {
    border-color: #ffffff;
}

.kb-card-btn img {
    display: block;
    height: 250px;
    width: auto;
    border-radius: 6px;
}

/* --- TREE OF LIFE --- */
#kb-tree-wrapper {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    justify-content: center;
}

#kb-tree-wrapper svg {
    height: 100%;
    max-width: 100%;
}

.kb-tree-svg .kb-hit { cursor: pointer; }

.kb-tree-hint {
    color: #777777;
    font-size: 0.8em;
    text-align: center;
    margin-top: 4px;
}

/* --- CARD AND MEANING OF THE SELECTION --- */
#kb-detail {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
}

.kb-detail-grid {
    display: grid;
    grid-template-columns: minmax(0, 300px) minmax(0, 1fr);
    gap: 16px;
    align-items: start;
}

.kb-detail-card {
    width: 100%;
    height: auto;
    border-radius: 8px;
}

.kb-detail-text h3 {
    margin: 0 0 4px;
    color: #ffffff;
    font-size: 1.3em;
}

.kb-detail-text h4 {
    margin: 0 0 8px;
    color: #cccccc;
    font-size: 0.85em;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.kb-detail-text p {
    margin: 0 0 8px;
    color: #bbbbbb;
    font-size: 0.9em;
    line-height: 1.55;
}

.kb-detail-text .kb-detail-summary {
    color: #dddddd;
    font-style: italic;
}

.kb-keywords {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin: 4px 0 10px;
}

.kb-keywords span {
    padding: 2px 8px;
    border: 1px solid #333333;
    border-radius: 10px;
    color: #aaaaaa;
    font-size: 0.75em;
}

table.icosmo-table.kb-detail-table th {
    width: 34%;
    text-align: left;
}

/* --- TABLES --- */
.table-wrapper {
    overflow-x: auto;
}

.kb-paths-table tbody tr,
.kb-sephiroth-table tbody tr {
    cursor: pointer;
}

.kb-hebrew {
    font-size: 1.25em;
    font-family: 'Arial Hebrew', 'Times New Roman', serif;
}

.kb-muted { color: #777777; }

.kb-swatch {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 2px;
    margin-right: 6px;
    vertical-align: -1px;
}

.kb-key {
    display: inline-block;
    min-width: 26px;
    padding: 1px 6px;
    border-radius: 3px;
    font-weight: bold;
    text-align: center;
}

.kb-weight {
    display: inline-block;
    width: 80px;
    height: 8px;
    background-color: #222222;
    border-radius: 4px;
    overflow: hidden;
    vertical-align: middle;
}

.kb-weight-fill {
    display: block;
    height: 100%;
}

.kb-note {
    margin: 8px 0 0;
    color: #777777;
    font-size: 0.8em;
}

/* --- NARROW SCREENS --- */
@container (max-width: 715px) {
    #kb-tree-module { height: 640px; }
    #kb-track-module { min-height: 350px; }
    #kb-detail-module { max-height: none; }
    .kb-detail-grid { grid-template-columns: 1fr; }
    .kb-detail-card { max-width: 300px; justify-self: center; }
    .kb-card-btn img { height: 220px; }
}

@media (max-width: 700px) {
    .am-row-main, .am-row-geo, .am-row-city, .am-bottom-buttons {
        flex-direction: column;
        align-items: stretch;
    }
    #icosmo-kabbalah-container { padding: 8px; }
}

/* --- PDF PRINT LAYOUT: white pages --- */
.kb-pdf-holder {
    position: absolute;
    left: 0;
    top: 0;
    width: 0;
    height: 0;
    overflow: hidden;
}

.kb-pdf-doc {
    width: 1000px;
    box-sizing: border-box;
    background-color: #ffffff;
    color: #1a1a1a;
    font-family: Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
}

.kb-pdf-doc .kb-pdf-section { margin-top: 26px; }

.kb-pdf-doc .kb-pdf-heading {
    margin: 0 0 12px;
    padding-bottom: 6px;
    border-bottom: 1px solid #999999;
    color: #1a1a1a;
    font-size: 1em;
    font-weight: bold;
    letter-spacing: 0.5px;
}

.kb-pdf-header {
    display: flex;
    align-items: center;
    gap: 26px;
    padding-bottom: 18px;
    border-bottom: 2px solid #1a1a1a;
}

.kb-pdf-logo {
    flex: 0 0 auto;
    width: 170px;
    height: 170px;
    border-radius: 8px;
}

.kb-pdf-title { flex: 1 1 auto; }

.kb-pdf-brand {
    font-size: 2.5em;
    line-height: 1.15;
}

.kb-pdf-subtitle {
    margin: 6px 0 14px;
    color: #555555;
    font-size: 1.05em;
    letter-spacing: 1px;
}

.kb-pdf-doc table.kb-pdf-meta,
.kb-pdf-doc table.kb-pdf-meta tr,
.kb-pdf-doc table.kb-pdf-meta th,
.kb-pdf-doc table.kb-pdf-meta td {
    background: transparent !important;
    border: none !important;
}

.kb-pdf-doc table.kb-pdf-meta { border-collapse: collapse; }

.kb-pdf-doc table.kb-pdf-meta th,
.kb-pdf-doc table.kb-pdf-meta td {
    padding: 2px 14px 2px 0;
    text-align: left;
    vertical-align: top;
    color: #1a1a1a !important;
}

.kb-pdf-doc table.kb-pdf-meta th { color: #555555 !important; }

.kb-pdf-brandmark {
    flex: 0 0 190px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.kb-pdf-brandmark img {
    width: 100px;
    height: 100px;
}

.kb-pdf-link {
    max-width: 190px;
    color: #1a5fb4;
    font-size: 0.85em;
    text-align: center;
    text-decoration: underline;
    word-break: break-all;
}

/* Summary in print colours */
.kb-pdf-doc .kb-summary { padding: 0; font-size: 15px; color: #1a1a1a; }
.kb-pdf-doc .kb-summary strong { color: #1a1a1a; }
.kb-pdf-doc .kb-summary-small,
.kb-pdf-doc .kb-pillar-name { color: #555555; }
.kb-pdf-doc .kb-pillar-value { color: #1a1a1a; }
.kb-pdf-doc .kb-pillars { max-width: 520px; }
.kb-pdf-doc .kb-pillar-track { background-color: #e6e6e6; }
.kb-pdf-doc .kb-pillar-fill { background-color: #555555; }

/* Tree and birth cards side by side */
.kb-pdf-tree-row {
    display: flex;
    gap: 30px;
    align-items: flex-start;
}

.kb-pdf-tree { flex: 0 0 440px; }
.kb-pdf-tree svg { width: 420px; height: auto; display: block; }
.kb-pdf-cards { flex: 1 1 auto; }

.kb-pdf-birthcards {
    display: flex;
    gap: 16px;
}

.kb-pdf-birthcard {
    text-align: center;
    color: #555555;
    font-size: 0.85em;
}

.kb-pdf-birthcard img {
    display: block;
    width: 220px;
    height: auto;
    margin-bottom: 6px;
    border-radius: 6px;
}

/* The strongest paths: card and meaning */
.kb-pdf-doc .kb-detail-grid { grid-template-columns: 220px 1fr; }
.kb-pdf-doc .kb-detail-text h3 { color: #1a1a1a; }
.kb-pdf-doc .kb-detail-text h4 { color: #555555; }
.kb-pdf-doc .kb-detail-text p { color: #1a1a1a; }
.kb-pdf-doc .kb-detail-text .kb-detail-summary { color: #333333; }
.kb-pdf-doc .kb-keywords span { border-color: #cccccc; color: #555555; }

/* Tables in light print styles (as in Icosmo Human Design) */
.kb-pdf-doc .table-wrapper { overflow: visible; }

.kb-pdf-doc table.icosmo-table {
    width: 100%;
    border-collapse: collapse;
    background-color: #ffffff;
    font-size: 0.82em;
}

.kb-pdf-doc table.icosmo-table th,
.kb-pdf-doc table.icosmo-table td {
    padding: 5px 8px;
    border: 1px solid #ffffff !important;
    background-color: #ececec !important;
    color: #1a1a1a !important;
    text-align: left;
    vertical-align: middle;
}

.kb-pdf-doc table.icosmo-table th {
    background-color: #d4d4d4 !important;
    font-weight: bold;
}

.kb-pdf-doc table.icosmo-table tbody tr:nth-child(even) > td { background-color: #e2e2e2 !important; }
.kb-pdf-doc table.icosmo-table td .kb-muted { color: #666666 !important; }
.kb-pdf-doc .kb-weight { background-color: #d0d0d0; }
.kb-pdf-doc .kb-note { color: #555555; }
