/* Shared layout for the TreeLights calculators; sits on top of w3.css */

.tl-page {
    padding-bottom: 16px;
}
.tl-page h3 {
    margin-bottom: 8px;
}

/* Shape tabs */
.tl-tabs {
    margin-bottom: 16px;
    overflow: hidden;
}
.tl-tabs .w3-bar-item {
    padding: 8px 16px;
}
.tl-tabs .w3-green {
    font-weight: 600;
}

/* Two columns on large screens: controls left, viewer right (sticky).
   One column below 993px with the viewer first so results are visible straight away. */
.tl-layout {
    display: grid;
    grid-template-columns: minmax(320px, 5fr) 7fr;
    gap: 16px;
    align-items: start;
}
.tl-viewer {
    position: sticky;
    top: 59px;
    min-width: 0;
}
@media (max-width: 992px) {
    .tl-layout {
        grid-template-columns: 1fr;
    }
    .tl-viewer {
        position: static;
        order: -1;
    }
}

/* Form cards */
.tl-section {
    padding: 4px 16px 12px;
    margin-bottom: 16px;
}
.tl-section h5 {
    margin: 8px 0 12px;
    font-weight: 600;
}
.tl-field {
    display: grid;
    grid-template-columns: 1fr minmax(160px, 50%);
    align-items: center;
    gap: 4px 12px;
    margin-bottom: 8px;
}
.tl-field .w3-input {
    padding: 6px 8px;
}
/* −/+ steppers built by treelights.js around number inputs */
.tl-spin {
    display: flex;
    align-items: stretch;
    min-width: 0;
}
.tl-spin .w3-input {
    flex: 1 1 auto;
    min-width: 0;
    text-align: center;
    border-radius: 0;
    border-left: none !important;
    border-right: none !important;
    -moz-appearance: textfield;
    appearance: textfield;
}
.tl-spin .w3-input::-webkit-inner-spin-button,
.tl-spin .w3-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.tl-spin-btn {
    flex: 0 0 40px;
    padding: 0;
    border: 1px solid #ccc;
    background: #f1f1f1;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}
.tl-spin-btn:hover {
    background: #ddd;
}
.tl-spin-btn:active {
    background: #c8e6c9;
}
.tl-spin-btn:first-child {
    border-radius: 4px 0 0 4px;
}
.tl-spin-btn:last-child {
    border-radius: 0 4px 4px 0;
}
@media (max-width: 600px) {
    .tl-spin-btn {
        flex-basis: 48px;
        min-height: 44px;
    }
}
.tl-field-wide {
    grid-template-columns: 1fr;
}
.tl-unit {
    color: #757575;
}
@media (max-width: 480px) {
    .tl-field {
        grid-template-columns: 1fr;
    }
}
.tl-hint {
    font-size: 13px;
    color: #616161;
    margin: 4px 0;
}

/* Colour pattern chips and preview */
.tl-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 8px 0;
}
.tl-chip {
    min-width: 40px;
    padding: 3px 8px;
    border: 1px solid rgba(0, 0, 0, 0.25);
    border-radius: 14px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}
.tl-chip:hover {
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}
.tl-preview {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    min-height: 22px;
}
.tl-swatch {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 1px solid rgba(0, 0, 0, 0.3);
}
.tl-swatch.tl-unknown {
    outline: 2px dashed #f44336;
    outline-offset: 1px;
}

/* Display toggles */
.tl-toggles {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 24px;
}
.tl-toggles label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}
input[type="color"] {
    height: 25px;
    width: 40px;
    padding: 1px;
    border: 1px solid #ccc;
    border-radius: 3px;
    cursor: pointer;
    background: none;
}
input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}
input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: 2px;
}

/* Result tiles */
.tl-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(95px, 1fr));
    gap: 10px;
    margin-bottom: 12px;
    min-height: 62px;
}
.tl-stat {
    padding: 8px 12px;
    text-align: center;
}
.tl-stat-value {
    font-size: 22px;
    font-weight: 600;
    line-height: 1.2;
}
.tl-stat-label {
    font-size: 12px;
    color: #616161;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.tl-error {
    grid-column: 1 / -1;
    padding: 12px 16px;
}

/* 3D view */
#canvas-container {
    height: min(600px, 65vh);
    min-height: 300px;
    overflow: hidden;
    background: #222;
}
#canvas-container canvas {
    display: block;
}
.tl-viewbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    margin-top: 8px;
}
.tl-viewbar input[type="range"] {
    flex: 1 1 160px;
}
.tl-zoom-readout {
    min-width: 120px;
    font-variant-numeric: tabular-nums;
}

/* Dark mode (body.dark-mode, palette from w3style.css). The light greys above
   vanish on the dark surfaces, so steppers get a raised fill and the muted
   text a lighter grey. */
body.dark-mode .tl-spin-btn {
    background: var(--dm-hover);
    border-color: var(--dm-line-strong);
    color: #eee;
}
body.dark-mode .tl-spin-btn:hover {
    background: #555;
}
body.dark-mode .tl-spin-btn:active {
    background: #2e7d32;
}
body.dark-mode .tl-unit,
body.dark-mode .tl-hint,
body.dark-mode .tl-stat-label {
    color: #aaa;
}
body.dark-mode .tl-chip,
body.dark-mode .tl-swatch {
    border-color: rgba(255, 255, 255, 0.35);
}
body.dark-mode input[type="color"] {
    border-color: var(--dm-line-strong);
}
