@font-face { font-family: 'OA Selkea'; src: url('/fonts/Lato-Bold.ttf') format('truetype'); font-display: swap; }
@font-face { font-family: 'OA Otsikko'; src: url('/fonts/Anton-Regular.ttf') format('truetype'); font-display: swap; }
@font-face { font-family: 'OA Rento'; src: url('/fonts/Pacifico-Regular.ttf') format('truetype'); font-display: swap; }
@font-face { font-family: 'OA Klassinen'; src: url('/fonts/DMSerifDisplay-Regular.ttf') format('truetype'); font-display: swap; }

:root {
    --bg: #F4EFE6;
    --surface: #FFFDF9;
    --ink: #2A2826;
    --muted: #6E675F;
    --line: #E2D9C9;
    --accent: #2F5D62;
    --accent-ink: #F4EFE6;
    --open: #3F5A45;
    --closed: #9E3B33;
    --error: #9E3B33;
    --radius: 14px;
    --shadow: 0 1px 2px rgba(42, 40, 38, .06), 0 4px 16px rgba(42, 40, 38, .06);
    --tap: 48px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

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

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font: 16px/1.5 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

main { padding: 0 16px 48px; }

h1, h2 { line-height: 1.2; margin: 0 0 .6em; }
h1 { font-size: clamp(1.6rem, 5vw, 2.4rem); }
h2 { font-size: 1.15rem; }

a { color: var(--accent); }

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    max-width: 1200px;
    margin: 0 auto;
}
.brand { font-family: 'OA Otsikko', sans-serif; font-size: 1.5rem; color: var(--ink); text-decoration: none; letter-spacing: .02em; }
.brand span { color: var(--open); }

.narrow { max-width: 520px; margin: 0 auto; }

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    margin-bottom: 16px;
}

label, .field-label { display: block; font-weight: 600; margin: 16px 0 6px; }
.card > h2 + label, .card > h1 + label, .card > h1 + input + label { margin-top: 0; }

input[type=email], input:not([type]), input[type=text], textarea {
    width: 100%;
    min-height: var(--tap);
    padding: 10px 12px;
    font: inherit;
    color: var(--ink);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 10px;
}
textarea { resize: vertical; }
input:focus-visible, textarea:focus-visible, button:focus-visible, .button:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent);
    outline-offset: 2px;
}

.check { display: flex; align-items: center; gap: 10px; font-weight: 500; margin: 12px 0; min-height: 32px; }
.check input { width: 22px; height: 22px; accent-color: var(--accent); flex: none; }
.check .hint { white-space: nowrap; }

.hint { color: var(--muted); font-size: .9rem; font-weight: 400; }
.upload-note { margin: 8px 0 0; }
.terms-check { margin-bottom: 4px; }
.terms-check + .hint { margin-top: 0; }
.terms h2 { margin-top: 1.4em; }
.terms ul { padding-left: 1.2em; }
.terms li { margin-bottom: .4em; }
.error { color: var(--error); font-weight: 600; }
.devnote { background: #FFF4D6; border: 1px dashed var(--muted); border-radius: 10px; padding: 12px; margin-top: 16px; white-space: pre-wrap; }

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: var(--tap);
    padding: 0 20px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #fff;
    color: var(--ink);
    font: inherit;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}
.button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.button.small { min-height: 40px; padding: 0 16px; font-size: .95rem; }
.button:disabled { opacity: .6; cursor: wait; }
form .button.primary { width: 100%; margin-top: 16px; }

.linkbutton {
    background: none;
    border: 0;
    padding: 8px 0;
    color: var(--accent);
    font: inherit;
    text-decoration: underline;
    cursor: pointer;
}

/* ---------- Etusivu ---------- */

.hero { padding-top: 24px; }
.lead { font-size: 1.15rem; margin-bottom: 24px; }
.tag-open { color: var(--open); }
.tag-closed { color: var(--closed); }
.features { list-style: none; padding: 0; display: grid; gap: 8px; }
.features li { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }

/* ---------- Hallinta ---------- */

.dash {
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    gap: 16px;
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "sign" "preview" "settings";
}
.sign-card { grid-area: sign; }
.preview-card { grid-area: preview; }
.settings { grid-area: settings; min-width: 0; }

.sign-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    text-align: center;
}
.status-label { margin: 0; color: var(--muted); font-size: .9rem; text-transform: uppercase; letter-spacing: .08em; }
.status-text { font-family: 'OA Otsikko', sans-serif; font-size: 3.2rem; line-height: 1.1; margin: 4px 0; letter-spacing: .03em; }
.status-text.is-open { color: var(--open); }
.status-text.is-closed { color: var(--closed); }
.status-detail { margin: 0 0 16px; color: var(--muted); min-height: 1.5em; }

.sign-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.sign-btn {
    min-height: 72px;
    border-radius: 12px;
    border: 2px solid currentColor;
    background: #fff;
    font: 1.6rem 'OA Otsikko', sans-serif;
    letter-spacing: .05em;
    cursor: pointer;
    transition: background .15s, color .15s;
}
.sign-open { color: var(--open); }
.sign-closed { color: var(--closed); }
.sign-open.is-active { background: var(--open); color: #fff; border-color: var(--open); }
.sign-closed.is-active { background: var(--closed); color: #fff; border-color: var(--closed); }
.sign-btn:disabled { opacity: .6; }

.preview-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
}
.preview-frame {
    position: relative;
    margin: 12px auto 4px;
    background: #E8DCC4;
    border-radius: 10px;
    overflow: hidden;
    aspect-ratio: 9 / 16;
    max-height: 62vh;
    display: flex;
    justify-content: center;
}
.preview-frame[data-format=nelio] { aspect-ratio: 1; }
.preview-frame[data-format=levea] { aspect-ratio: 1200 / 630; }
.preview-frame img { width: 100%; height: 100%; object-fit: contain; display: block; }
.preview-loading {
    position: absolute; right: 8px; top: 8px;
    background: rgba(42, 40, 38, .75); color: #fff; font-size: .8rem;
    padding: 2px 10px; border-radius: 999px;
}
.preview-card > .hint { text-align: center; margin: 4px 0 12px; }

.share-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.embed { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 8px; }
.embed summary { cursor: pointer; font-weight: 600; min-height: 40px; display: flex; align-items: center; }
.embed textarea { font: .85rem/1.4 ui-monospace, monospace; margin-bottom: 8px; }
#public-link { word-break: break-all; }

.segmented {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.segmented button, .font-grid button {
    flex: 1 1 0;
    min-height: 44px;
    padding: 6px 10px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    color: var(--ink);
    font: inherit;
    font-size: .95rem;
    cursor: pointer;
    white-space: nowrap;
}
.segmented button.is-active, .font-grid button.is-active {
    border-color: var(--accent);
    background: var(--accent);
    color: var(--accent-ink);
}

.font-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.font-grid button { display: flex; flex-direction: column; align-items: center; gap: 0; padding: 8px; min-height: 72px; }
.font-grid small { font-size: 1.6rem; line-height: 1.2; }
.font-selkea small { font-family: 'OA Selkea'; }
.font-otsikko small { font-family: 'OA Otsikko'; }
.font-rento small { font-family: 'OA Rento'; }
.font-klassinen small { font-family: 'OA Klassinen'; }

.color-targets button { position: relative; padding-left: 28px; }
.color-targets button::before {
    content: '';
    position: absolute; left: 9px; top: 50%;
    width: 14px; height: 14px; margin-top: -7px;
    border-radius: 50%;
    background: var(--c);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, .2);
}
.swatches { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 6px; margin: 12px 0 8px; }
.swatch {
    aspect-ratio: 1;
    min-width: 0;
    padding: 0;
    border-radius: 10px;
    border: 1px solid rgba(0, 0, 0, .15);
    background: var(--c);
    cursor: pointer;
}
.swatch.is-active { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--ink); }

.upload-row { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 16px; }

.schedule { display: grid; gap: 4px; }
/* Puhelimessa päivän nimi ja kellonajat omille riveilleen, leveämmällä rinnakkain. */
.day-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 4px 8px;
    padding: 6px 0;
    border-bottom: 1px solid var(--line);
}
.day-row .check { margin: 0; }
.day-times { grid-column: 1 / -1; display: flex; align-items: center; gap: 6px; padding-left: 32px; }
.day-times input {
    flex: 1 1 0;
    min-width: 0;
    min-height: 44px;
    padding: 6px 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    font: inherit;
    background: #fff;
    color: var(--ink);
}
.day-closed { display: none; color: var(--muted); justify-self: end; }
.day-row.is-closed .day-times { display: none; }
.day-row.is-closed .day-closed { display: block; }
@media (min-width: 560px) {
    .day-row { grid-template-columns: minmax(130px, 1fr) minmax(0, 300px); }
    .day-times { grid-column: auto; padding-left: 0; }
}

.slug-row { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; background: #fff; overflow: hidden; }
.slug-row span { padding-left: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 55%; }
.slug-row input { border: 0; padding-left: 0; border-radius: 0; min-width: 0; }

.savebar {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    background: var(--ink);
    color: var(--bg);
    z-index: 10;
}
.savebar span { flex: 1; min-width: 0; font-weight: 600; line-height: 1.25; }
.savebar .button { padding: 0 16px; flex: none; }
.savebar .button:not(.primary) { background: transparent; color: var(--bg); border-color: rgba(255, 255, 255, .3); }
.savebar .button.primary { background: var(--bg); color: var(--ink); border-color: var(--bg); }
body.has-savebar main { padding-bottom: 96px; }

.toast {
    position: fixed;
    left: 50%; bottom: 88px;
    transform: translateX(-50%);
    max-width: calc(100% - 32px);
    background: var(--open);
    color: #fff;
    padding: 10px 18px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    z-index: 20;
    text-align: center;
}
.toast.is-error { background: var(--error); }

/* ---------- Julkinen sivu ---------- */

.public { text-align: center; padding-top: 16px; }
.public-status { font-family: 'OA Otsikko', sans-serif; font-size: 4rem; margin: 0 0 16px; line-height: 1; }
.public-status.is-open { color: var(--open); }
.public-status.is-closed { color: var(--closed); }
.public-image { width: 100%; height: auto; border-radius: var(--radius); box-shadow: var(--shadow); }
.hours-list { list-style: none; padding: 0; font-size: 1.1rem; }

/* ---------- Tietokone: kaksi saraketta ---------- */

@media (min-width: 900px) {
    main { padding: 0 24px 48px; }
    .dash {
        grid-template-columns: minmax(0, 1fr) minmax(360px, 440px);
        grid-template-areas: "sign preview" "settings preview";
        align-items: start;
        gap: 20px 24px;
    }
    .preview-card { position: sticky; top: 16px; grid-row: 1 / span 2; }
    .preview-frame { max-height: 60vh; }
    .sign-card { display: grid; grid-template-columns: 1fr auto; text-align: left; align-items: center; gap: 0 16px; }
    .sign-card .status-label, .sign-card .status-text, .sign-card .status-detail { grid-column: 1; }
    .sign-card .sign-buttons { grid-column: 2; grid-row: 1 / span 3; grid-template-columns: 150px 150px; }
    .sign-card .linkbutton { grid-column: 1 / -1; justify-self: start; }
    .toast { bottom: 32px; }
    body.has-savebar .toast { bottom: 88px; }
}
