/* Startside - fælles stil for offentlig visning, login og builder.
   Temaets accent/radius/maxbredde kommer fra /theme.css, som loades efter denne fil. */

:root {
    --bg: #f4f6fa;
    --surface: #ffffff;
    --surface-2: #eef1f7;
    --surface-3: #e4e9f2;
    --text: #12151c;
    --muted: #5d6675;
    --line: #e2e7ef;
    --line-strong: #cfd7e4;
    --danger: #c93c3c;
    --warn: #a06a12;
    --accent: #4f8cff;
    --accent-text: #ffffff;
    --accent-soft: color-mix(in srgb, #4f8cff 14%, transparent);
    --radius: 14px;
    --maxw: 1180px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 10px 28px -14px rgba(16, 24, 40, .18);
    --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #0e1116;
        --surface: #161a21;
        --surface-2: #1d232c;
        --surface-3: #252d38;
        --text: #e8ecf3;
        --muted: #9aa5b5;
        --line: #262e3a;
        --line-strong: #39445434;
        --danger: #ef6b6b;
        --warn: #d9a441;
        --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 12px 32px -16px rgba(0, 0, 0, .7);
    }
}

:root[data-theme="dark"] {
    --bg: #0e1116;
    --surface: #161a21;
    --surface-2: #1d232c;
    --surface-3: #252d38;
    --text: #e8ecf3;
    --muted: #9aa5b5;
    --line: #262e3a;
    --line-strong: #394454;
    --danger: #ef6b6b;
    --warn: #d9a441;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 12px 32px -16px rgba(0, 0, 0, .7);
}

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

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

body {
    margin: 0;
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
    background-image: radial-gradient(60rem 30rem at 50% -10%, var(--accent-soft), transparent 70%);
    background-repeat: no-repeat;
    min-height: 100vh;
}

h1, h2, h3, h4 {
    line-height: 1.2;
    margin: 0 0 .5rem;
}

p {
    margin: 0 0 .75rem;
}

p:last-child {
    margin-bottom: 0;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: .9em;
    background: var(--surface-2);
    padding: .1em .35em;
    border-radius: 5px;
}

ul {
    margin: 0 0 .75rem;
    padding-left: 1.1rem;
}

/* ---------- Layout ---------- */

.wrap {
    width: 100%;
    max-width: var(--maxw);
    margin-inline: auto;
    padding-inline: 1.1rem;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    background: color-mix(in srgb, var(--bg) 82%, transparent);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
}

.topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    min-height: 3.6rem;
    flex-wrap: wrap;
}

.brand {
    font-weight: 700;
    font-size: 1.02rem;
    letter-spacing: -.01em;
    color: var(--text);
}

.brand:hover {
    text-decoration: none;
    color: var(--accent);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: .45rem;
    flex-wrap: wrap;
}

.page {
    display: grid;
    gap: 1.15rem;
    padding-block: 1.5rem 2.5rem;
}

.section {
    display: grid;
}

.page-footer {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    padding-block: 1.25rem 2.5rem;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: .8rem;
}

/* ---------- Grid og spalter ---------- */

.grid {
    display: grid;
    gap: 1.15rem;
    align-items: start;
}

.cols-1 { grid-template-columns: minmax(0, 1fr); }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-2.r-2-1 { grid-template-columns: 2fr 1fr; }
.cols-2.r-1-2 { grid-template-columns: 1fr 2fr; }
.cols-3.r-2-1-1 { grid-template-columns: 2fr 1fr 1fr; }
.cols-3.r-1-2-1 { grid-template-columns: 1fr 2fr 1fr; }
.cols-3.r-1-1-2 { grid-template-columns: 1fr 1fr 2fr; }

.column {
    display: grid;
    gap: 1.15rem;
    align-content: start;
    min-width: 0;
}

/* ---------- Kort ---------- */

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.05rem 1.15rem;
    overflow: hidden;
}

.card-title {
    font-size: .78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--muted);
    padding-bottom: .55rem;
    margin-bottom: .8rem;
    border-bottom: 1px solid var(--line);
}

.card-missing {
    border-style: dashed;
}

.hint {
    color: var(--muted);
    font-size: .82rem;
    margin: 0;
    padding-left: .65rem;
    border-left: 3px solid var(--line-strong);
}

.hint-warn {
    color: var(--warn);
    border-left-color: var(--warn);
    margin-top: .7rem;
}

.empty-state {
    background: var(--surface);
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius);
    padding: 3rem 1.5rem;
    text-align: center;
    color: var(--muted);
}

.empty-state h1 {
    color: var(--text);
    font-size: 1.4rem;
}

/* ---------- Blokke ---------- */

.blk-heading {
    letter-spacing: -.02em;
    margin: 0;
}

h1.blk-heading { font-size: 2rem; }
h2.blk-heading { font-size: 1.45rem; }
h3.blk-heading { font-size: 1.15rem; }

.blk-text > :last-child {
    margin-bottom: 0;
}

.blk-text ul {
    margin-bottom: .5rem;
}

.blk-links {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: .2rem;
}

.blk-links a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .6rem;
    padding: .42rem .55rem;
    border-radius: calc(var(--radius) - 8px);
    color: var(--text);
    font-size: .88rem;
    transition: background .12s ease, color .12s ease;
}

.blk-links a:hover {
    background: var(--accent-soft);
    color: var(--accent);
    text-decoration: none;
}

.blk-link-arrow {
    color: var(--muted);
    font-size: .8rem;
    opacity: 0;
    transition: opacity .12s ease, transform .12s ease;
}

.blk-links a:hover .blk-link-arrow {
    opacity: 1;
    transform: translateX(2px);
}

.blk-links-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .45rem;
}

.blk-links-grid a {
    border: 1px solid var(--line);
    background: var(--surface-2);
    font-weight: 500;
}

.blk-image {
    margin: 0;
}

.blk-image img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: calc(var(--radius) - 6px);
}

.blk-image-cover img {
    height: 220px;
    object-fit: cover;
}

.blk-image figcaption {
    margin-top: .5rem;
    color: var(--muted);
    font-size: .78rem;
}

/* Kalender */

.cal-month {
    border: 1px solid var(--line);
    border-radius: calc(var(--radius) - 4px);
    overflow: hidden;
}

.cal-month-title {
    padding: .5rem .7rem;
    font-weight: 600;
    font-size: .86rem;
    background: var(--surface-2);
    text-transform: capitalize;
}

.cal-weekdays {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    font-size: .64rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--muted);
    border-bottom: 1px solid var(--line);
    background: var(--surface-2);
}

.cal-weekdays span {
    padding: .3rem .2rem;
    text-align: center;
}

.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
}

.cal-cell {
    position: relative;
    min-height: 62px;
    padding: .28rem .3rem;
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    font-size: .68rem;
    min-width: 0;
}

.cal-cell:nth-child(7n) {
    border-right: 0;
}

.cal-cell.other-month {
    background: var(--surface-2);
    color: var(--muted);
    opacity: .6;
}

.cal-cell.today {
    box-shadow: inset 0 0 0 2px var(--accent);
    background: var(--accent-soft);
}

.cal-daynum {
    display: block;
    font-weight: 700;
    font-size: .68rem;
    margin-bottom: .18rem;
    font-variant-numeric: tabular-nums;
}

.cal-events {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: .12rem;
}

.cal-events li {
    background: var(--accent-soft);
    border-left: 2px solid var(--accent);
    border-radius: 3px;
    padding: .04rem .22rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: .64rem;
}

.cal-events li.all-day {
    font-weight: 600;
}

.cal-events li.more {
    background: transparent;
    border-left-color: transparent;
    color: var(--muted);
}

.cal-upcoming {
    display: grid;
    gap: .8rem;
    margin-top: 1rem;
}

.cal-day-label {
    font-size: .68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--muted);
    margin-bottom: .22rem;
}

.cal-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: .1rem;
}

.cal-item {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: .1rem .6rem;
    align-items: baseline;
    padding: .28rem .4rem;
    border-radius: calc(var(--radius) - 9px);
}

.cal-item:hover {
    background: var(--surface-2);
}

.cal-time {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    font-size: .74rem;
    color: var(--accent);
    min-width: 4.7rem;
}

.cal-title {
    font-size: .86rem;
    overflow-wrap: anywhere;
}

.cal-loc {
    grid-column: 2;
    font-size: .72rem;
    color: var(--muted);
}

/* Email */

.mail-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: .1rem;
}

.mail-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0 .6rem;
    padding: .34rem .4rem;
    border-radius: calc(var(--radius) - 9px);
    font-size: .84rem;
}

.mail-item:hover {
    background: var(--surface-2);
}

.mail-from {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
}

.mail-item.unread .mail-from {
    font-weight: 700;
}

.mail-item.unread .mail-from::after {
    content: "";
    display: inline-block;
    width: 6px;
    height: 6px;
    margin-left: .35rem;
    border-radius: 50%;
    background: var(--accent);
    vertical-align: middle;
}

.mail-subject {
    grid-column: 1;
    color: var(--muted);
    font-size: .8rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mail-date {
    grid-row: 1 / span 2;
    grid-column: 2;
    align-self: center;
    color: var(--muted);
    font-size: .7rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* ---------- Knapper og formularer ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .35rem;
    padding: .42rem .8rem;
    font: inherit;
    font-size: .84rem;
    font-weight: 500;
    line-height: 1.3;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: calc(var(--radius) - 6px);
    cursor: pointer;
    transition: background .12s ease, border-color .12s ease, color .12s ease, opacity .12s ease;
    text-decoration: none;
}

.btn:hover {
    background: var(--surface-2);
    text-decoration: none;
}

.btn:disabled {
    opacity: .5;
    cursor: default;
}

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-text);
}

.btn-primary:hover {
    background: color-mix(in srgb, var(--accent) 84%, #000);
    border-color: color-mix(in srgb, var(--accent) 84%, #000);
}

.btn-ghost {
    background: transparent;
    border-color: transparent;
    color: var(--muted);
}

.btn-ghost:hover {
    background: var(--surface-2);
    color: var(--text);
}

.btn-icon {
    width: 2.1rem;
    height: 2.1rem;
    padding: 0;
    font-size: .95rem;
    color: var(--muted);
}

.btn-danger {
    color: var(--danger);
}

.btn-danger:hover {
    background: color-mix(in srgb, var(--danger) 12%, transparent);
    color: var(--danger);
}

.btn-block {
    width: 100%;
}

.inline-form {
    display: inline;
    margin: 0;
}

.field {
    display: grid;
    gap: .3rem;
    margin-bottom: .8rem;
}

.field-label {
    font-size: .78rem;
    font-weight: 600;
    color: var(--muted);
}

.input,
textarea.input,
select.input {
    width: 100%;
    padding: .48rem .6rem;
    font: inherit;
    font-size: .88rem;
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--line-strong);
    border-radius: calc(var(--radius) - 8px);
}

.input:focus-visible,
.btn:focus-visible,
a:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

textarea.input {
    resize: vertical;
    min-height: 5rem;
    line-height: 1.5;
}

.field-help {
    font-size: .72rem;
    color: var(--muted);
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: .86rem;
    margin-bottom: .8rem;
}

.checkbox-row input {
    width: 1rem;
    height: 1rem;
    accent-color: var(--accent);
}

.alert {
    padding: .6rem .8rem;
    border-radius: calc(var(--radius) - 8px);
    font-size: .84rem;
    margin: 0 0 1rem;
    border: 1px solid var(--line-strong);
    background: var(--surface-2);
}

.alert-error {
    color: var(--danger);
    border-color: color-mix(in srgb, var(--danger) 40%, transparent);
    background: color-mix(in srgb, var(--danger) 10%, transparent);
}

/* ---------- Login ---------- */

.login-body {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 1.5rem;
}

.login-wrap {
    width: 100%;
    max-width: 24rem;
}

.login-card {
    padding: 1.6rem;
}

.login-title {
    font-size: 1.3rem;
    margin-bottom: .2rem;
}

.login-sub {
    color: var(--muted);
    font-size: .85rem;
    margin-bottom: 1.1rem;
}

.login-foot {
    margin: 1rem 0 0;
    text-align: center;
    font-size: .8rem;
    color: var(--muted);
}

/* ---------- Responsivt ---------- */

@media (max-width: 900px) {
    .cols-2,
    .cols-3,
    .cols-2.r-2-1,
    .cols-2.r-1-2,
    .cols-3.r-2-1-1,
    .cols-3.r-1-2-1,
    .cols-3.r-1-1-2 {
        grid-template-columns: minmax(0, 1fr);
    }

    .blk-links-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .cal-cell {
        min-height: 52px;
    }
}

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