/* style.css
   Sizes and colors of the flap clock and the converter.
   The light palette comes from stylesheet-light.css, the dark palette
   from stylesheet-dark.css, both in ../gnome-shell-clock/. Three dark
   values have no source there, because the GNOME shell theme gives
   them: --housing, --signal, and --button with --button-text.
   The flap sizes come from ../gnome-shell-clock/layout.css. */

:root {
    --housing: #d6d8db;
    --flap: #34373c;
    --hinge: #1f2124;
    --glyph: #edeef0;
    --signal: #f3c41a;
    --text: #34373c;
    --dim: #5a5e64;
    --track: rgba(52, 55, 60, 0.15);
    --line: rgba(52, 55, 60, 0.3);
    --field: #edeef0;
    --button: #34373c;
    --button-text: #edeef0;
    --error: #9b1c10;
}

@media (prefers-color-scheme: dark) {
    :root {
        /* No manual theme switch: the browser picks the palette. */
        --housing: #060518;
        --flap: #131a54;
        --hinge: #060518;
        --glyph: #f0a508;
        --signal: #f0a508;
        --text: #f2f2f7;
        --dim: rgba(255, 255, 255, 0.6);
        --track: rgba(255, 255, 255, 0.15);
        --line: rgba(255, 255, 255, 0.25);
        --field: #0d1238;
        --button: #131a54;
        --button-text: #f0a508;
        --error: #ff9a8a;
    }
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    margin: 0;
    background: var(--housing);
    color: var(--text);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 15px;
    line-height: 1.4;
}

main {
    max-width: calc(530px + 2 * clamp(16px, 4vw, 22px));
    margin: 0 auto;
    padding: 22px clamp(16px, 4vw, 22px) 48px;
}

h1 {
    margin: 0 0 4px;
    font-size: 22px;
    font-weight: 600;
}

h2 {
    margin: 0 0 14px;
    font-size: 17px;
    font-weight: 600;
}

p {
    margin: 0;
}

a {
    color: inherit;
}

header {
    margin-bottom: 26px;
}

.hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

.dim {
    color: var(--dim);
}

:focus-visible {
    outline: 2px solid var(--text);
    outline-offset: 2px;
}

.clock {
    container-type: inline-size;
    display: flex;
    flex-direction: column;
    gap: 18px;
    margin-bottom: 40px;
}

/* .clock is a size container, so cqi below reads its own width and
   not the width of the page. --s is one design pixel: below 420px
   (or 530px with the cycle tile) it shrinks, above it it stays at
   1px, so the flap row never grows past its design size. --ref is
   the width of the tiles and their gaps: 5 * 76 + 4 * 10 = 420,
   420 + 10 + 100 = 530 with the sixth, wide tile. This keeps the
   flap row inside a screen of 320px. */
.flaps {
    --ref: 420;
    --s: min(1px, calc(100cqi / var(--ref)));
    display: flex;
    justify-content: center;
    gap: calc(10 * var(--s));
}

.flaps.has-cycle {
    --ref: 530;
}

.tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.tile[hidden] {
    display: none;
}

.flap {
    position: relative;
    display: grid;
    place-items: center;
    width: calc(76 * var(--s));
    height: calc(104 * var(--s));
    margin: 0;
    padding: 0;
    overflow: hidden;
    border: 0;
    border-radius: calc(7 * var(--s));
    background: var(--flap);
    color: var(--glyph);
    font: inherit;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.flap.wide {
    width: calc(100 * var(--s));
}

/* An inset box-shadow, not a border, so the active flap keeps its size. */
.flap.on {
    box-shadow: inset 0 0 0 max(1px, calc(2 * var(--s))) var(--glyph);
}

.glyph {
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-size: calc(70 * var(--s));
    font-weight: 600;
    line-height: 1;
}

.glyph.flip {
    animation: flip 350ms ease-in-out;
}

@keyframes flip {
    from {
        transform: translateY(-50%);
        opacity: 0;
    }
}

.hinge {
    position: absolute;
    top: 50%;
    right: 0;
    left: 0;
    height: max(1px, calc(2 * var(--s)));
    background: var(--hinge);
    transform: translateY(-50%);
}

.caption {
    font-size: 11px;
}

.track,
.signal {
    height: 5px;
    border-radius: 3px;
}

.track {
    background: var(--track);
}

.signal {
    width: 0;
    background: var(--signal);
}

.aid {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ruler {
    display: grid;
    grid-template-columns: repeat(32, 1fr);
    margin: 0;
    padding: 0;
    list-style: none;
}

/* A narrow container gets 16 columns of 2 characters instead of 32
   columns of 1 character. */
@container (max-width: 400px) {
    .ruler {
        grid-template-columns: repeat(16, 1fr);
    }
}

.cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    padding: 3px 0;
    border-radius: 3px;
    color: var(--dim);
}

.cell.on {
    background: var(--flap);
    color: var(--glyph);
}

.ruler-character {
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.2;
}

.ruler-value {
    font-size: 8px;
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
}

.hint {
    min-height: 1.4em;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

.hint.on {
    color: var(--text);
}

.footer {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
}

.utc {
    font-size: 15px;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

.local,
.next {
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

.next {
    white-space: nowrap;
}

.button {
    margin: 0;
    padding: 6px 14px;
    border: 0;
    border-radius: 6px;
    background: var(--button);
    color: var(--button-text);
    font: inherit;
    font-size: 13px;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    cursor: pointer;
}

.button.small {
    padding: 3px 10px;
    font-size: 12px;
}

.converter form + form {
    margin-top: 18px;
}

fieldset {
    min-width: 0;
    margin: 0;
    padding: 14px 16px 16px;
    border: 1px solid var(--line);
    border-radius: 7px;
}

legend {
    padding: 0 6px;
    font-size: 13px;
    font-weight: 600;
}

.field label {
    display: block;
    margin-bottom: 4px;
    color: var(--dim);
    font-size: 12px;
}

.control {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

input[type="datetime-local"],
input[type="text"] {
    flex: 1 1 200px;
    min-width: 0;
    max-width: 100%;
    padding: 7px 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--field);
    color: var(--text);
    font: inherit;
    /* 16px, so iOS Safari does not zoom into the field. */
    font-size: 16px;
    font-variant-numeric: tabular-nums;
}

input.code {
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    letter-spacing: 0.08em;
}

input[aria-invalid="true"] {
    border-color: var(--error);
}

.choice {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 18px;
    margin-top: 10px;
    font-size: 13px;
}

.choice input {
    margin: 0 4px 0 0;
    accent-color: var(--signal);
}

.result:empty {
    display: none;
}

.result {
    margin-top: 14px;
}

.rows {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: baseline;
    gap: 8px 12px;
    margin: 0;
}

.rows dt {
    color: var(--dim);
    font-size: 12px;
}

.rows dd {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    min-width: 0;
    margin: 0;
}

.value {
    min-width: 0;
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
}

.value-code {
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-size: 17px;
    font-weight: 600;
    letter-spacing: 0.08em;
}

.value-link {
    font-size: 12px;
}

.parts {
    margin: 12px 0 0;
    padding: 10px 0 0;
    border-top: 1px solid var(--line);
    color: var(--dim);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    list-style: none;
}

.error {
    color: var(--error);
    font-size: 13px;
}

.status {
    position: fixed;
    bottom: 18px;
    left: 50%;
    max-width: calc(100vw - 32px);
    padding: 6px 14px;
    border-radius: 6px;
    background: var(--button);
    color: var(--button-text);
    font-size: 13px;
    transform: translateX(-50%);
    overflow-wrap: anywhere;
}

/* copy.js sets and clears the text of #status. Hidden while empty,
   so nothing shows before the first copy. */
.status:empty {
    visibility: hidden;
}

@media (max-width: 420px) {
    .rows {
        grid-template-columns: minmax(0, 1fr);
        gap: 2px;
    }

    .rows dt {
        margin-top: 8px;
    }
}

@media (prefers-reduced-motion: reduce) {
    /* The flap still shows the new character, with no animation. */
    .glyph.flip {
        animation: none;
    }
}
