/* === GLIDE Engineering - Terminal Styles === */

/* === Terminal Container === */
.terminal {
    min-height: clamp(8rem, 32vh, 14rem);
    max-height: none;
    height: auto;
    overflow-y: hidden;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    flex: 1 1 auto;
}

/* Safari iOS specific fix */
@supports (-webkit-touch-callout: none) {
    .terminal {
        overflow: visible; /* Critical for Safari */
        -webkit-overflow-scrolling: touch;
        min-height: 0;
        height: auto;
        display: -webkit-flex;
        -webkit-flex-direction: column;
        flex-direction: column;
        -webkit-flex: 1 1 auto;
        flex: 1 1 auto;
    }
}

/* === Terminal Lines === */
.terminal-line {
    display: flex;
    align-items: flex-start;
    margin-bottom: clamp(0.125rem, 0.5vh, 0.3125rem);
    min-height: clamp(1rem, 3.5vh, 1.25rem);
    width: 100%;
    flex-shrink: 0;
}

/* Safari iOS specific */
@supports (-webkit-touch-callout: none) {
    .terminal-line {
        display: -webkit-flex;
        -webkit-align-items: flex-start;
        align-items: flex-start;
        -webkit-flex-shrink: 0;
        flex-shrink: 0;
        min-height: auto;
        height: auto;
    }
}

/* Hidden lines initially */
#running-line,
#result-line,
#suggestion-line,
#interactive-line {
    display: none;
    margin-top: clamp(0.125rem, 0.5vh, 0.25rem);
}

.terminal-line:last-child {
    margin-bottom: 0;
}

.terminal-prompt {
    color: #8BE9FD;
    margin-right: clamp(0.375rem, 1.5vw, 0.5625rem);
    white-space: nowrap;
    flex-shrink: 0;
    font-weight: 500;
    font-size: clamp(0.75rem, 3vw, 0.9375rem);
}

.terminal-line-content {
    flex: 1;
    word-wrap: break-word;
    overflow-wrap: break-word;
    position: relative;
    line-height: clamp(1.3, 1.4, 1.5);
    font-size: clamp(0.75rem, 3vw, 0.9375rem);
}

/* Safari iOS specific fix */
@supports (-webkit-touch-callout: none) {
    .terminal-line-content {
        -webkit-flex: 1;
        flex: 1;
        overflow: visible;
        word-break: break-word;
        -webkit-line-break: after-white-space;
        line-break: after-white-space;
        white-space: normal;
    }
}

/* === Command Colors === */
.cmd-pink {
    color: #EB068C;
    font-weight: 500;
}

.cmd-white {
    color: #FFFFFF;
}

.cmd-accent {
    color: #EB068C;
    font-weight: 500;
}

/* === Animated Cursor === */
.cursor {
    display: inline-block;
    width: clamp(0.375rem, 1.5vw, 0.5625rem);
    height: clamp(0.875rem, 3.5vh, 1.125rem);
    background-color: #FFFFFF;
    margin-left: 0.2rem;
    animation: cursorBlink 1s step-end infinite;
    vertical-align: text-bottom;
}

@keyframes cursorBlink {
    from, to { opacity: 1; }
    50% { opacity: 0; }
}

/* === Interactive Input === */
.terminal-input {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    font-family: inherit;
    font-size: inherit;
    background: transparent;
    border: none;
    color: #FFFFFF;
    outline: none;
    caret-color: transparent;
}

/* Prevent zoom on iOS */
@supports (-webkit-touch-callout: none) {
    .terminal-input {
        font-size: 16px !important;
    }
}

#custom-input {
    display: inline;
    min-width: 0.5rem;
}

/* === Brochure Link === */
[data-brochure="true"] {
    cursor: pointer;
    text-decoration: underline;
    text-decoration-style: dotted;
    text-underline-offset: 0.2em;
    transition: all 0.3s ease;
}

[data-brochure="true"]:hover {
    color: #FF60C0;
    text-shadow: 0 0 0.5rem rgba(235, 6, 140, 0.5);
    text-decoration-style: solid;
}

[data-brochure="true"]:active {
    transform: scale(0.95);
}

/* === Terminal Notifications === */
.terminal-notification {
    margin-top: clamp(0.125rem, 0.5vh, 0.25rem);
    padding: clamp(0.125rem, 0.5vh, 0.25rem) 0;
    opacity: 0;
    animation: fadeInNotification 0.5s ease forwards;
    max-height: clamp(1.5rem, 6vh, 2rem);
    overflow: hidden;
}

.terminal-notification .terminal-line-content {
    font-size: clamp(0.6875rem, 2.75vw, 0.8125rem);
}

.terminal-notification .cmd-accent {
    animation: pulseText 2s ease-in-out infinite;
    font-size: clamp(0.6875rem, 2.75vw, 0.8125rem);
}

@keyframes fadeInNotification {
    to { opacity: 1; }
}

@keyframes pulseText {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* === Additional Effects === */
.pulse-effect {
    animation: pulse 0.6s ease;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.fade-out {
    animation: fadeOut 0.3s ease forwards;
}

@keyframes fadeOut {
    to {
        opacity: 0;
        transform: translateY(-8px);
    }
}

/* === Responsive Design === */

/* Mobile */
@media (max-width: 768px) {
    .terminal {
        min-height: clamp(7.5rem, 34vh, 11rem);
        max-height: none;
        padding: clamp(0.5rem, 2vh, 0.75rem) clamp(0.625rem, 2.5vw, 0.875rem);
    }
    
    .terminal-line {
        margin-bottom: clamp(0.0625rem, 0.3vh, 0.1875rem);
        min-height: clamp(0.875rem, 3.5vh, 1.125rem);
    }
    
    .terminal-prompt {
        font-size: clamp(0.625rem, 2.5vw, 0.8125rem);
    }
    
    .terminal-line-content {
        font-size: clamp(0.625rem, 2.5vw, 0.8125rem);
    }
    
    .cursor {
        width: clamp(0.3125rem, 1.25vw, 0.5rem);
        height: clamp(0.75rem, 3vh, 1rem);
    }
}

/* Medium screens */
@media (min-width: 768px) and (max-width: 1200px) {
    .terminal {
        min-height: clamp(10rem, 36vh, 14rem);
        max-height: none;
    }
    
    .terminal-line {
        margin-bottom: clamp(0.125rem, 0.5vh, 0.25rem);
        min-height: clamp(0.9375rem, 3.75vh, 1.125rem);
    }
    
    .terminal-prompt,
    .terminal-line-content {
        font-size: clamp(0.75rem, 3vw, 0.875rem);
    }
    
    .cursor {
        width: clamp(0.3125rem, 1.25vw, 0.5rem);
        height: clamp(0.8125rem, 3.25vh, 1rem);
    }
}

/* Large screens - OTTIMIZZATO PER LAPTOP 17" */
@media (min-width: 1200px) {
    .terminal {
        min-height: 14rem;
        max-height: none;
    }
    
    .terminal-line {
        margin-bottom: 0.375rem;
        min-height: 1.5rem;
    }
    
    /* Font più grandi per laptop/desktop */
    .terminal-prompt,
    .terminal-line-content {
        font-size: 1.125rem; /* Aumentato da 0.9375rem */
    }
    
    .cursor {
        width: 0.625rem;
        height: 1.375rem;
    }
    
    .terminal-notification {
        margin-top: 0.3125rem;
        padding: 0.3125rem 0;
        max-height: 2.25rem;
    }
    
    .terminal-notification .terminal-line-content,
    .terminal-notification .cmd-accent {
        font-size: 1rem; /* Aumentato */
    }
}

/* Extra large screens (4K, ultra-wide) */
@media (min-width: 1920px) {
    .terminal-prompt,
    .terminal-line-content {
        font-size: 1.25rem; /* Ancora più grande per schermi molto grandi */
    }
    
    .terminal-notification .terminal-line-content,
    .terminal-notification .cmd-accent {
        font-size: 1.125rem;
    }
}

/* Small mobile - OTTIMIZZATO PER IPHONE */
@media (max-width: 414px) {
    .terminal {
        min-height: clamp(7.5rem, 38vh, 10rem);
        max-height: none;
        height: auto;
        padding: clamp(0.375rem, 1.5vh, 0.5rem) clamp(0.4375rem, 1.75vw, 0.5625rem);
        line-height: 1.25;
    }
    
    .terminal-line {
        margin-bottom: 0.0625rem;
        min-height: 0.875rem;
    }
    
    #running-line,
    #result-line,
    #suggestion-line,
    #interactive-line {
        margin-top: clamp(0.0625rem, 0.25vh, 0.125rem);
    }
    
    .terminal-prompt,
    .terminal-line-content {
        font-size: clamp(0.5625rem, 2.25vw, 0.6875rem);
        line-height: 1.2;
    }
    
    .terminal-prompt {
        margin-right: clamp(0.3125rem, 1.25vw, 0.4375rem);
    }
    
    .cursor {
        width: clamp(0.25rem, 1vw, 0.375rem);
        height: clamp(0.6875rem, 2.75vh, 0.875rem);
        margin-left: 0.125rem;
    }
    
    .terminal-notification .terminal-line-content,
    .terminal-notification .cmd-accent {
        font-size: 0.5rem;
    }
    
    .terminal-notification {
        margin-top: 0.0625rem;
        padding: 0.0625rem 0;
        max-height: 1.375rem;
    }
}

/* Smaller devices */
@media (max-width: 480px) {
    .terminal {
        min-height: clamp(7rem, 35vh, 10rem);
        max-height: none;
    }
}

/* Ultra small */
@media (max-width: 375px) {
    .terminal {
        min-height: clamp(6.5rem, 36vh, 9rem);
        max-height: none;
        padding: clamp(0.3125rem, 1.25vh, 0.4375rem) clamp(0.375rem, 1.5vw, 0.4375rem);
    }
    
    .terminal-line {
        margin-bottom: 0rem;
        min-height: 0.75rem;
    }
    
    #running-line,
    #result-line,
    #suggestion-line,
    #interactive-line {
        margin-top: 0.0625rem;
    }
    
    .terminal-prompt,
    .terminal-line-content {
        font-size: clamp(0.5rem, 2vw, 0.625rem);
        line-height: 1.15;
    }
    
    .terminal-prompt {
        margin-right: 0.25rem;
    }
    
    .cursor {
        width: 0.1875rem;
        height: 0.5625rem;
        margin-left: 0.0625rem;
    }
}

/* Landscape mode */
@media (max-height: 700px) {
    .terminal {
        min-height: clamp(7rem, 33vh, 12rem);
        max-height: none;
    }
    
    .terminal-line {
        margin-bottom: clamp(0.0625rem, 0.25vh, 0.1875rem);
        min-height: clamp(0.75rem, 3vh, 1rem);
    }
    
    .terminal-prompt,
    .terminal-line-content {
        font-size: clamp(0.625rem, 2.5vw, 0.75rem);
    }
    
    .cursor {
        width: clamp(0.25rem, 1vw, 0.375rem);
        height: clamp(0.6875rem, 2.75vh, 0.875rem);
    }
}

/* Ultra landscape */
@media (max-height: 600px) {
    .terminal {
        min-height: clamp(5rem, 38vh, 8rem);
        max-height: none;
        flex: 1 1 auto;
    }
    
    .terminal-line {
        margin-bottom: clamp(0.0625rem, 0.25vh, 0.125rem);
        min-height: clamp(0.75rem, 3vh, 1rem);
    }
    
    .terminal-prompt,
    .terminal-line-content {
        font-size: clamp(0.5625rem, 2.25vw, 0.6875rem);
    }
    
    .cursor {
        width: clamp(0.25rem, 1vw, 0.3125rem);
        height: clamp(0.625rem, 2.5vh, 0.8125rem);
    }
}

/* Mobile landscape */
@media (max-width: 768px) and (max-height: 500px) {
    .terminal {
        min-height: clamp(4rem, 38vh, 5.5rem);
        max-height: none;
        height: auto;
        padding: clamp(0.1875rem, 0.75vh, 0.25rem) clamp(0.25rem, 1vw, 0.3125rem);
        flex: 1 1 auto;
    }
    
    .terminal-line {
        margin-bottom: 0;
        min-height: 0.5625rem;
    }
    
    #running-line,
    #result-line,
    #suggestion-line,
    #interactive-line {
        margin-top: 0;
    }
    
    .terminal-prompt,
    .terminal-line-content {
        font-size: 0.5rem;
        line-height: 1.05;
    }
    
    .cursor {
        width: 0.125rem;
        height: 0.5rem;
    }
}

/* Ultra small height */
@media (max-height: 400px) {
    .terminal {
        min-height: clamp(3.5rem, 38vh, 4.5rem);
        max-height: none;
        height: auto;
        flex: 1 1 auto;
    }
}

/* iPhone SE */
@media (max-width: 320px) {
    .terminal {
        min-height: clamp(5.5rem, 36vh, 7.5rem);
        max-height: none;
        padding: 0.1875rem 0.25rem;
    }
    
    .terminal-prompt,
    .terminal-line-content {
        font-size: 0.5rem;
    }
}

/* === Accessibility === */
@media (prefers-reduced-motion: reduce) {
    .cursor,
    .terminal-notification .cmd-accent {
        animation: none;
    }
    
    .cursor {
        opacity: 1;
    }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .terminal-prompt,
    .terminal-line-content {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}