/* Stile minimal: un solo font, bianco e nero, niente decorazioni.
   Le pagine PHP caricano solo questo file, quindi tutto lo stile è qui. */

@import url("https://fonts.googleapis.com/css2?family=Geist:wght@400;500;600&family=Geist+Mono&display=swap");

:root {
    --sfondo: #ffffff;
    --testo: #111111;
    --grigio: #6b6b6b;
    --linea: #e6e6e6;
    --campo: #f5f5f5;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --sfondo: #141414;
        --testo: #ededed;
        --grigio: #8f8f8f;
        --linea: #2a2a2a;
        --campo: #1d1d1d;
        color-scheme: dark;
    }
}

* {
    box-sizing: border-box;
}

html {
    background: var(--sfondo);
}

body {
    max-width: 600px;
    margin: 0 auto;
    padding: 96px 20px;
    font-family: "Geist", system-ui, sans-serif;
    font-size: 16px;
    line-height: 1.7;
    color: var(--testo);
    font-variant-numeric: tabular-nums;
    -webkit-font-smoothing: antialiased;
}

h1 {
    margin: 0 0 40px;
    font-size: 32px;
    line-height: 1.2;
    font-weight: 600;
    letter-spacing: -0.02em;
}

/* Le pagine PHP stampano solo testo: le righe vanno a capo come nel codice
   e la prima riga fa da titolo */
body:not(:has(h1)) {
    white-space: pre-line;
}

body:not(:has(h1))::first-line {
    font-size: 32px;
    font-weight: 600;
    letter-spacing: -0.02em;
}

/* Elenchi di pagine */
.menu a {
    display: block;
    padding: 12px 0;
    border-bottom: 1px solid var(--linea);
    color: var(--testo);
    text-decoration: none;
    transition: color .15s;
}

.menu a {
    display: flex;
    justify-content: space-between;
    gap: 16px;
}

.menu a::after {
    content: "→";
    color: var(--grigio);
    transition: transform .15s;
}

.menu a:hover {
    color: var(--grigio);
}

.menu a:hover::after {
    transform: translateX(4px);
}

/* Moduli */
form {
    margin: 0 0 24px;
    white-space: normal;
}

input, select, textarea, button {
    font: inherit;
    color: inherit;
}

input[type="text"],
input[type="number"],
input[type="password"],
select {
    height: 44px;
    padding: 0 14px;
    margin: 4px 6px 4px 0;
    border: 1px solid var(--linea);
    border-radius: 8px;
    background: var(--campo);
    vertical-align: middle;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--testo);
}

button {
    height: 44px;
    padding: 0 20px;
    margin: 4px 6px 4px 0;
    border: 1px solid var(--testo);
    border-radius: 8px;
    background: var(--testo);
    color: var(--sfondo);
    font-weight: 500;
    cursor: pointer;
    vertical-align: middle;
    transition: opacity .15s;
}

button:hover {
    opacity: .8;
}

br + button {
    margin-top: 16px;
}

/* Bottoni con i numeri */
button[name="tab"] {
    width: 44px;
    padding: 0;
    border-color: var(--linea);
    background: transparent;
    color: var(--testo);
    font-weight: 400;
}

button[name="tab"]:hover {
    opacity: 1;
    border-color: var(--testo);
}

/* Pulsanti radio: si vede solo il numero, quello scelto è pieno */
label:has(input[type="radio"]) {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    margin: 4px 6px 4px 0;
    border: 1px solid var(--linea);
    border-radius: 8px;
    cursor: pointer;
}

label:has(input[type="radio"]:checked) {
    border-color: var(--testo);
    background: var(--testo);
    color: var(--sfondo);
}

label:has(input[type="radio"]:focus-visible) {
    outline: 2px solid var(--testo);
    outline-offset: 2px;
}

input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

/* Slider */
input[type="range"] {
    width: min(100%, 320px);
    margin: 12px 12px 12px 0;
    accent-color: var(--testo);
    vertical-align: middle;
}

#valore {
    font-weight: 600;
}

/* Immagine cliccabile */
input[type="image"] {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
}

/* Compilatore: codice e output */
textarea, pre {
    font-family: "Geist Mono", ui-monospace, monospace;
    font-size: 14px;
    line-height: 1.6;
    border-radius: 8px;
    background: var(--campo);
}

textarea {
    display: block;
    width: 100%;
    margin: 0 0 8px;
    padding: 16px;
    border: 1px solid var(--linea);
    tab-size: 4;
    resize: vertical;
}

pre {
    margin: 0 0 24px;
    padding: 16px;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

/* Spazio su disco */
progress {
    appearance: none;
    display: block;
    width: 100%;
    height: 6px;
    border: 0;
    border-radius: 3px;
    background: var(--linea);
    overflow: hidden;
}

progress::-webkit-progress-bar {
    background: var(--linea);
}

progress::-webkit-progress-value {
    background: var(--testo);
}

progress::-moz-progress-bar {
    background: var(--testo);
}

/* Link per tornare indietro */
.indietro {
    display: inline-block;
    margin-top: 48px;
    color: var(--grigio);
    text-decoration: none;
}

.indietro::before {
    content: "← ";
}

.indietro:hover {
    color: var(--testo);
}

a:focus-visible, button:focus-visible {
    outline: 2px solid var(--testo);
    outline-offset: 2px;
}

@media (max-width: 520px) {
    body {
        padding-top: 56px;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
    }
}
