@import url("colours.css");

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--background);
    color: var(--text);
    height: 100dvh;
    /* full device height */
    overflow: hidden;
    /* prevent page scroll */
}

/* Root container fills screen */
.container {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    /* lock layout to one viewport */
    width: 100%;
    background: linear-gradient(180deg, var(--background) 0%, var(--secondary) 100%);
}

/* Top Controls Section - fixed height */
.top-controls {
    flex-shrink: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    padding: 16px;
    background: var(--background);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    z-index: 10;
}

.brewer-section,
.roast-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.section-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.9;
}

.vertical-select {
    background: var(--background);
    border: 2px solid var(--primary);
    border-radius: 8px;
    padding: 10px 8px;
    font-size: 13px;
    color: var(--text);
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
}

.vertical-select:focus {
    outline: none;
    border-color: var(--accent);
    background: linear-gradient(135deg, var(--background) 0%, rgba(255, 255, 255, 0.5) 100%);
}

/* Display sections */
.ratio-display,
.temp-display {
    background: var(--background);
    border: 2px solid var(--accent);
    border-radius: 8px;
    padding: 8px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.display-label {
    font-size: 10px;
    color: var(--primary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.8;
}

.display-value {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    margin-top: 4px;
}

/* Center section: flexible + scrollable */
.center-calculations {
    flex: 1;
    min-height: 0;
    /* allow flex scroll fix */
    overflow-y: auto;
    /* internal scroll if needed */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 16px;
    padding: 12px;
    width: 100%;
}

.input-section {
    text-align: center;
    animation: floatIn 0.5s ease;
}

.input-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Responsive weight input */
.weight-input {
    width: clamp(120px, 40vw, 220px);
    background: linear-gradient(135deg, var(--background) 0%, rgba(255, 255, 255, 0.9) 100%);
    border: 3px solid var(--primary);
    border-radius: 16px;
    padding: clamp(10px, 3vh, 20px);
    font-size: clamp(20px, 6vw, 40px);
    text-align: center;
    color: var(--text);
    font-weight: 700;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.weight-input:focus {
    outline: none;
    border-color: var(--accent);
    transform: scale(1.05);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.15);
}

.output-section {
    text-align: center;
    animation: floatIn 0.5s ease 0.1s backwards;
}

.output-label {
    display: block;
    font-size: 12px;
    color: var(--primary);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

/* Responsive water display */
.water-display {
    background: var(--background);
    border: 3px solid var(--accent);
    border-radius: 16px;
    padding: clamp(8px, 2vh, 20px) clamp(16px, 6vw, 40px);
    font-size: clamp(18px, 5vw, 36px);
    font-weight: 700;
    color: var(--text);
    min-width: clamp(100px, 40vw, 160px);
    display: inline-block;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}

/* Info panel: acts only as container for cycling */
.info-panel {
    position: relative;
    width: 100%;
    max-width: 360px;
    height: clamp(80px, 18vh, 160px);
    /* dynamic height */
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    /* cards fade in/out here */
    background: transparent;
    /* no pill background */
    border: none;
    box-shadow: none;
    border-radius: 0;
    padding: 0;
}

/* Info card: floating single card */
.info-card {
    position: absolute;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.6s ease, transform 0.6s ease;
    background: var(--secondary);
    border-radius: 12px;
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    max-width: 90%;
    display: flex;
    align-items: center;
    gap: 10px;
    text-align: left;
}

/* Show active card */
.info-card.active {
    opacity: 1;
    transform: translateY(0);
    position: relative;
}

/* Icon badge */
.info-icon {
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--primary);
    color: var(--background);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
}

/* Timer Section - fixed at bottom */
.timer-section {
    flex-shrink: 0;
    background: var(--background);
    border: 2px solid var(--primary);
    border-radius: 24px 24px 0 0;
    padding: 20px 16px 24px 16px;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Phase Indicator */
.phase-indicator {
    text-align: center;
    padding: 12px;
    background: var(--secondary);
    border-radius: 12px;
    border: 2px solid var(--accent);
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.05);
}

.current-phase {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.phase-name {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.5px;
}

.phase-instruction {
    font-size: 12px;
    color: var(--text);
    opacity: 0.8;
    font-style: italic;
}

/* Compact Timer Display */
.timer-compact {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 8px;
}

.timer-btn {
    width: clamp(36px, 12vw, 60px);
    height: clamp(36px, 12vw, 60px);
    background: var(--primary);
    border: 2px solid var(--text);
    border-radius: 50%;
    color: var(--background);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.timer-btn:hover {
    background: var(--accent);
    transform: scale(1.05);
}

.timer-btn:active {
    transform: scale(0.92);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.timer-btn svg {
    width: 24px;
    height: 24px;
    fill: var(--background);
}

.reset-btn {
    width: clamp(28px, 10vw, 44px);
    height: clamp(28px, 10vw, 44px);
    background: var(--background);
    border: 2px solid var(--primary);
    border-radius: 50%;
    color: var(--primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.reset-btn:hover {
    background: var(--secondary);
    border-color: var(--accent);
}

.reset-btn:active {
    background: var(--primary);
    color: var(--background);
    transform: scale(0.92);
}

.reset-btn svg {
    width: 18px;
    height: 18px;
}

.timer-display {
    flex: 1;
    text-align: center;
}

.time-text {
    font-size: clamp(20px, 8vw, 40px);
    font-weight: 700;
    color: var(--text);
    font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
    letter-spacing: 1px;
    line-height: 1;
}

.phase-time {
    font-size: 11px;
    color: var(--primary);
    margin-top: 4px;
    opacity: 0.8;
    font-weight: 600;
}

/* Phase Progress Bar */
.phase-progress-container {
    position: relative;
    height: clamp(32px, 7vh, 56px);
    margin: 8px 0;
}

.phase-progress {
    display: flex;
    height: clamp(24px, 6vh, 44px);
    position: relative;
    z-index: 2;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
    border: 2px solid var(--primary);
}

.phase-segment {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 600;
    color: var(--background);
    position: relative;
    transition: all 0.3s ease;
    cursor: pointer;
    overflow: hidden;
    padding: 4px;
}

.phase-segment::after {
    content: '';
    position: absolute;
    right: 0;
    top: 20%;
    height: 60%;
    width: 1px;
    background: var(--background);
    opacity: 0.3;
}

.phase-segment:last-child::after {
    display: none;
}

/* Phase colors */
.phase-segment.bloom {
    background: var(--primary);
}

.phase-segment.pour {
    background: var(--accent);
}

.phase-segment.stir {
    background: var(--primary);
    opacity: 0.9;
}

.phase-segment.wait {
    background: var(--secondary);
    color: var(--text);
}

.phase-segment.drawdown {
    background: var(--accent);
    opacity: 0.9;
}

.phase-segment.active {
    transform: scaleY(1.1);
    box-shadow: inset 0 0 20px rgba(255, 255, 255, 0.3);
    z-index: 3;
}

.phase-segment.completed {
    opacity: 0.5;
    background: var(--secondary);
    color: var(--text);
}

.phase-segment .phase-label {
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 9px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.phase-segment .phase-duration {
    display: none;
}

.progress-line {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--secondary);
    border-radius: 2px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: var(--primary);
    transition: width 0.1s linear;
    box-shadow: 0 0 8px var(--accent);
}

/* Only one card visible at a time */
.info-panel {
    position: relative;
    height: clamp(80px, 20vh, 160px);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Hide all cards by default */
.info-card {
    position: absolute;
    opacity: 0;
    transition: opacity 0.8s ease-in-out;
}

/* Show active card */
.info-card.active {
    opacity: 1;
    position: relative;
}

/* Animations */
@keyframes floatIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.02);
    }
}

.timer-complete .phase-indicator {
    background: var(--accent);
    animation: pulse 1s infinite;
}

.timer-complete .phase-indicator .phase-name {
    color: var(--background);
}

/* Responsive tweaks for very short devices */
@media only screen and (max-height: 700px) {
    .center-calculations {
        gap: 12px;
        padding: 8px;
    }

    .info-panel {
        max-height: 35vh;
    }

    .timer-section {
        padding: 12px;
        gap: 8px;
    }
}