/*
 * Tor — dark theme layered on Pico.css v2 (data-theme="dark").
 * Shared design language with dnt.privatevoid.eu and frigg.privatevoid.eu:
 * GitHub-dark palette (#0d1117 / #161b22 / #30363d) with DNT red (#E2001A) accent.
 */

:root {
    --pico-font-size: 93.75%;
    --pico-background-color: #0d1117;
    /* Cards and borders sit a clear step above the page background so
       surfaces are distinguishable (bumped from GitHub-dark #161b22/#30363d). */
    --pico-card-background-color: #1b2330;
    --pico-card-sectioning-background-color: #232d3d;
    --pico-table-border-color: #414c5e;
    --pico-muted-border-color: #414c5e;
    /* Softer corners: buttons/inputs/pills follow Pico's radius, cards go rounder */
    --pico-border-radius: 0.5rem;
    --radius-card: 0.75rem;

    --accent: #E2001A;
    --accent-hover: #B8001A;
    --accent-ring: rgba(226, 0, 26, 0.2);
    --success: #27ae60;
}

/* --- Base --- */

html { scrollbar-gutter: stable; }

body {
    padding: 1rem;
}

a {
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

[x-cloak] {
    display: none !important;
}

/* --- Page chrome (same as DNT) --- */

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.page-header h1 {
    margin: 0;
    font-size: 1.5rem;
}

/* `inherit` (not var(--pico-color)): Pico redefines --pico-color to the primary
   colour on anchors, which would turn the brand link blue */
.page-header h1 a {
    color: inherit;
}

.page-header h1 a:hover {
    text-decoration: none;
    color: inherit;
}

.page-nav {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
}

.page-nav > a {
	padding: 0.4rem 0.85rem; border-radius: var(--pico-border-radius);
	text-decoration: none; white-space: nowrap;
	border: 1px solid var(--pico-form-element-border-color);
	background: var(--pico-form-element-background-color);
	color: var(--pico-form-element-color);
	font-size: 0.9rem; line-height: 1.2;
}
.page-nav > a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.page-nav > a.active { background: var(--accent); border-color: var(--accent); color: white; }
.page-nav > a.active:hover { color: white; text-decoration: none; }

.page-nav__user {
    color: var(--pico-muted-color);
    font-size: 0.9rem;
    padding: 0.35rem 0.25rem;
}

.page-nav__logout {
    width: auto;
    margin: 0;
    padding: 0.35rem 0.75rem;
    border: none;
    border-radius: var(--pico-border-radius);
    background: transparent;
    color: var(--pico-muted-color);
    font: inherit;
    font-size: 0.9rem;
    cursor: pointer;
    box-shadow: none;
}

.page-nav__logout:hover {
    color: var(--pico-color);
    background: rgba(255, 255, 255, 0.08);
}

.page-nav__logout:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--accent-ring);
}

/* --- Hero / page intros --- */

.hero {
    padding: 0 0 1.25rem;
}

.home-hero {
    padding: 0 0 1.25rem;
}

.home-hero__title,
.hero__title {
    margin: 0 0 0.25rem;
    font-size: 1.25rem;
}

.home-hero__lead,
.hero__lead {
    margin: 0;
    max-width: 62ch;
    line-height: 1.55;
    color: var(--pico-muted-color);
    font-size: 0.95rem;
}

.hero__cta {
    margin: 0.75rem 0 0;
}

/* --- Home plan cards (whole card is a link to the plan page) --- */

.home-plans {
    display: grid;
    gap: 0.85rem;
    grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
}

.home-plan-card {
    display: block;
    margin: 0;
    border: 1px solid var(--pico-muted-border-color);
    background: var(--pico-card-background-color);
    border-radius: var(--radius-card);
    padding: 0.85rem 1rem 0.95rem;
    min-width: 0;
    box-shadow: none;
    color: inherit;
    text-decoration: none;
    transition: border-color 0.15s, background 0.15s;
}

.home-plan-card:hover {
    text-decoration: none;
    color: inherit;
    border-color: color-mix(in srgb, var(--pico-muted-border-color) 70%, white);
    background: color-mix(in srgb, var(--pico-card-background-color) 94%, white);
}

.home-plan-card__title {
    margin: 0 0 0.45rem;
    font-size: 1.05rem;
    font-weight: 700;
    min-width: 0;
    color: var(--pico-color);
}

.home-plan-card__empty {
    margin: 0;
    font-size: 0.9rem;
}

.home-plan-card__places {
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.home-plan-card__places li {
    margin: 0;
    padding: 0;
    color: var(--pico-muted-color);
    line-height: 1.35;
    font-size: 0.9rem;
    list-style: none;
}

.home-plan-card__places li::before {
    content: "·";
    margin-right: 0.4rem;
    color: var(--pico-muted-border-color);
    font-weight: 700;
}

/* --- Buttons (DNT recipes) --- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: auto;
    margin: 0;
    padding: 0.5rem 1rem;
    border-radius: var(--pico-border-radius);
    border: 1px solid var(--pico-form-element-border-color);
    background: var(--pico-form-element-background-color);
    color: var(--pico-form-element-color);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    transition: all 0.15s;
    box-shadow: none;
}

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

.btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--accent-ring);
}

/* Pico makes button[type=submit] full width; keep .btn buttons content-sized */
button.btn,
a.btn {
    width: auto;
}

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

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

.btn--ghost {
    background: transparent;
}

.btn--danger {
    color: var(--accent);
    border-color: color-mix(in srgb, var(--accent) 55%, var(--pico-muted-border-color));
    background: rgba(226, 0, 26, 0.08);
}

.btn--danger:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.btn--small {
    padding: 0.3rem 0.7rem;
    font-size: 0.9rem;
}

/* --- Utilities --- */

.mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.95em;
}

.muted {
    color: var(--pico-muted-color);
}

.small {
    font-size: 0.9rem;
}

.nowrap {
    white-space: nowrap;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* --- Public plan page --- */

.plan-page {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Row-major order: item 1,2,… left-to-right, then next row — matches foreach order.
   The Yr table widget only shows all its columns at ≥ 40rem, so a column is only
   created when a card can hold the full-width widget (40rem table + card padding).
   auto-fill counts tracks by the minmax() max, so the widget cap (66.67rem) lives
   on .place-card instead of the track definition. */
.plan-grid {
    display: grid;
    gap: 1.25rem;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 42.5rem), 1fr));
}

.plan-header__title {
    margin: 0 0 0.35rem;
    font-size: 1.25rem;
}

.plan-header__meta {
    margin: 0;
    color: var(--pico-muted-color);
}

.place-card {
    margin: 0;
    border: 1px solid var(--pico-muted-border-color);
    background: var(--pico-card-background-color);
    border-radius: var(--radius-card);
    padding: 1rem;
    min-width: 0;
    display: flex;
    flex-direction: column;
    box-shadow: none;
    /* Cap at the widget's max content width and centre within a wide track */
    width: 100%;
    max-width: 66.75rem;
    margin-inline: auto;
}

/* On containers narrower than the widget's full table (40rem) the card scrolls
   horizontally instead of letting the iframe silently crop the table columns. */
.place-card .yr-widget {
    flex: 1;
    min-height: 0;
    overflow-x: auto;
    border-radius: var(--pico-border-radius);
}

.place-card__head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.6rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}

.place-card__title {
    margin: 0;
    font-size: 1.15rem;
    flex: 1;
    min-width: 0;
}

.place-card__toggle-widget {
    flex-shrink: 0;
}

/* min-width keeps the widget at its full table layout (40rem); the natural
   content height is ~31rem, background matches the widget's dark mode. */
.yr-widget__frame {
    border: 0;
    border-radius: var(--pico-border-radius);
    background: #0a2343;
    display: block;
    width: 100%;
    min-width: 40rem;
    height: 35rem;
}

/* Utlandet (abroad) trip dashboards: day-by-day forecast cards rendered from Open-Meteo. */
.trip-stops {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.trip-stop__flag {
    margin-right: 0.35rem;
}

.trip-stop__meta {
    margin: 0.15rem 0 0;
    width: 100%;
}

.trip-stop__source {
    color: var(--accent);
}

.trip-stop__unavailable {
    margin: 0.5rem 0 0;
}

/* Horizontal strip of day cards; scrolls on narrow viewports rather than wrapping awkwardly.
   Near days carry a daypart breakdown and are taller, so cards top-align. */
.day-strip {
    display: flex;
    gap: 0.6rem;
    overflow-x: auto;
    padding-bottom: 0.35rem;
    align-items: flex-start;
}

.day-card {
    flex: 0 0 auto;
    width: 8.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
    padding: 0.6rem 0.5rem;
    border: 1px solid var(--pico-muted-border-color);
    border-radius: var(--pico-border-radius);
    background: var(--pico-background-color);
    text-align: center;
}

.day-card__weekday {
    font-weight: 600;
    text-transform: capitalize;
}

.day-card__date {
    color: var(--pico-muted-color);
    font-size: 0.85rem;
}

.day-card__symbol {
    width: 48px;
    height: 48px;
    margin: 0.25rem 0;
}

.day-card__label {
    text-transform: capitalize;
    min-height: 2.4em;
    display: flex;
    align-items: center;
}

.day-card__temps {
    display: flex;
    gap: 0.4rem;
    align-items: baseline;
    font-size: 1.05rem;
}

.day-card__tmax {
    font-weight: 600;
}

.day-card__detail {
    line-height: 1.3;
}

.day-card__placeholder {
    font-size: 1.6rem;
    color: var(--pico-muted-color);
    margin: 0.5rem 0;
}

/* Per-daypart breakdown (morning/midday/afternoon/evening) for the coming days. */
.dayparts {
    width: 100%;
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--pico-muted-border-color);
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.daypart {
    display: grid;
    grid-template-columns: 1fr auto auto;
    align-items: center;
    gap: 0.35rem;
    text-align: left;
}

.daypart__name {
    text-transform: capitalize;
}

.daypart__symbol {
    width: 24px;
    height: 24px;
}

.daypart__temp {
    font-weight: 600;
    justify-self: end;
}

.daypart__precip {
    grid-column: 1 / -1;
    justify-self: end;
    margin-top: -0.15rem;
}

.attribution {
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px dashed var(--pico-muted-border-color);
    color: var(--pico-muted-color);
    line-height: 1.55;
}

.error-title {
    margin-top: 0;
}

.error-dev h2 {
    font-size: 1rem;
    margin: 1.5rem 0 0.5rem;
}

.backoffice .muted {
    max-width: 80ch;
    line-height: 1.55;
}

/* Backoffice -------------------------------------------------------------- */

.backoffice-shell {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.backoffice-flash {
    margin: 0;
    padding: 0.75rem 1rem;
    border: 1px solid var(--success);
    background: rgba(39, 174, 96, 0.15);
    border-radius: var(--radius-card);
    color: var(--success);
}

.alpine-flash {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
}

.alpine-flash__text {
    flex: 1;
    min-width: 0;
    margin: 0;
    padding-top: 0.25rem;
    line-height: 1.45;
}

.alpine-flash__close {
    flex-shrink: 0;
}

.backoffice-heading__title {
    margin: 0 0 0.35rem;
    font-size: 1.25rem;
}

.backoffice-heading__lead,
.backoffice-heading__meta {
    margin: 0;
    line-height: 1.55;
}

.backoffice-breadcrumbs {
    margin: 0;
}

.backoffice-card {
    margin: 0;
    border: 1px solid var(--pico-muted-border-color);
    background: var(--pico-card-background-color);
    border-radius: var(--radius-card);
    padding: 1.1rem 1.1rem 1.15rem;
    box-shadow: none;
}

.backoffice-card--danger {
    border-color: color-mix(in srgb, var(--accent) 55%, var(--pico-muted-border-color));
}

.backoffice-card__title {
    margin: 0 0 0.85rem;
    font-size: 1.1rem;
}

.backoffice-stack {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.backoffice-section-title {
    margin: 0;
    font-size: 1.1rem;
}

/* --- Forms --- */

.form-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: 1fr;
}

@media (min-width: 900px) {
    .form-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        align-items: start;
    }
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-width: 0;
}

.form-field label {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--pico-muted-color);
    margin: 0;
}

.form-control {
    width: 100%;
    height: auto;
    margin: 0;
    padding: 0.45rem 0.65rem;
    border-radius: var(--pico-border-radius);
    border: 1px solid var(--pico-form-element-border-color);
    background: var(--pico-form-element-background-color);
    color: var(--pico-form-element-color);
    font-size: 0.95rem;
    box-shadow: none;
}

.form-control:focus,
.form-control:focus-visible {
    border-color: var(--accent);
    outline: none;
    box-shadow: 0 0 0 2px var(--accent-ring);
}

.field-hint {
    margin: 0;
}

.field-error {
    color: var(--accent);
    font-size: 0.92rem;
}

.validation-summary {
    color: var(--accent);
    font-size: 0.95rem;
    margin-bottom: 0.75rem;
}

.validation-summary ul {
    margin: 0.25rem 0 0 1.25rem;
    padding: 0;
}

/* --- Yr place search dropdown --- */

.yr-search {
    position: relative;
    width: 100%;
}

.yr-search__anchor {
    position: relative;
    width: 100%;
}

.yr-search__dropdown {
    position: absolute;
    top: calc(100% + 0.35rem);
    left: 0;
    right: 0;
    z-index: 30;
    border: 1px solid var(--pico-muted-border-color);
    border-radius: var(--radius-card);
    background: var(--pico-card-background-color);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
    max-height: 20rem;
    overflow-y: auto;
}

.yr-search__status {
    margin: 0;
    padding: 0.65rem 0.85rem;
}

.yr-search__list {
    list-style: none;
    margin: 0;
    padding: 0.25rem;
}

.yr-search__list li {
    margin: 0;
    padding: 0;
    list-style: none;
}

.yr-search__option {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    width: 100%;
    margin: 0;
    padding: 0.5rem 0.65rem;
    border: 0;
    border-radius: 0.35rem;
    background: transparent;
    color: var(--pico-color);
    text-align: left;
    font-size: 0.95rem;
    cursor: pointer;
    box-shadow: none;
}

.yr-search__option--active,
.yr-search__option:hover {
    background: rgba(255, 255, 255, 0.08);
}

.yr-search__option-name {
    font-weight: 650;
}

.backoffice-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: flex-start;
}

/* --- Tables --- */

.table-wrap {
    border: 1px solid var(--pico-muted-border-color);
    border-radius: var(--radius-card);
    overflow: auto;
    background: var(--pico-card-background-color);
}

.backoffice-table {
    width: 100%;
    margin: 0;
    border-collapse: collapse;
    min-width: 760px;
}

.backoffice-table th,
.backoffice-table td {
    text-align: left;
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--pico-muted-border-color);
    vertical-align: middle;
    background: transparent;
}

.backoffice-table thead th {
    font-size: 0.92rem;
    color: var(--pico-color);
    background: var(--pico-card-sectioning-background-color);
    border-bottom: 2px solid var(--pico-muted-border-color);
}

.backoffice-table tbody tr:last-child td {
    border-bottom: none;
}

.backoffice-table .num {
    text-align: right;
    white-space: nowrap;
}

.actions {
    white-space: nowrap;
}

.inline-form {
    display: inline;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.5rem;
    border-radius: 999px;
    border: 1px solid var(--pico-muted-border-color);
    background: rgba(255, 255, 255, 0.08);
    font-size: 0.82rem;
    font-weight: 700;
    white-space: nowrap;
}

.badge--muted {
    border-color: var(--pico-muted-border-color);
    background: rgba(255, 255, 255, 0.03);
    color: var(--pico-muted-color);
}

.pager {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    justify-content: space-between;
}

.pager__links {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* --- List reordering (drag and drop) --- */

.reorder-handle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    margin: 0;
    padding: 0;
    border: none;
    border-radius: var(--pico-border-radius);
    background: transparent;
    color: var(--pico-muted-color);
    cursor: grab;
    touch-action: none;
    box-shadow: none;
}

.reorder-handle:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--pico-color);
}

.reorder-handle:active {
    cursor: grabbing;
}

.reorder-cell {
    width: 2.5rem;
}

.reorder-row--ghost {
    opacity: 0.4;
}

.reorder-row--ghost td {
    box-shadow: inset 0 2px 0 var(--accent), inset 0 -2px 0 var(--accent);
}

/* --- Login (shared login box — wwwroot/css/login-box.css is a full copy of
       shared_resources/login-box.css from the dabendorf-odin workspace) --- */

body.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 1.25rem;
}

/* Fit the shared box into Tor's Pico dark design via the --login-* variables */
.login-box {
    --login-surface: var(--pico-card-background-color);
    --login-border: var(--pico-muted-border-color);
    --login-text: var(--pico-color);
    --login-muted: var(--pico-muted-color);
    --login-input-surface: var(--pico-form-element-background-color);
    --login-accent: var(--accent);
    --login-accent-contrast: #fff;
    --login-error: var(--accent);
}

/* Pico gives inputs a bottom margin; the box spaces fields itself */
.login-box-input {
    margin-bottom: 0;
}

/* Forced password change page (same box) */
.login-box-info {
    margin: 0 0 1rem;
    font-size: 0.875rem;
    color: var(--login-muted, var(--pico-muted-color));
}

.login-box-help {
    display: block;
    margin-top: 0.35rem;
    font-size: 0.75rem;
    color: var(--login-muted, var(--pico-muted-color));
}

/* Alpine interactions ----------------------------------------------------- */

.alpine-inline-confirm {
    position: relative;
    display: inline-block;
    vertical-align: middle;
}

.alpine-modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.alpine-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(1, 4, 9, 0.72);
    backdrop-filter: blur(2px);
}

.alpine-modal__panel {
    position: relative;
    z-index: 1;
    max-width: 28rem;
    width: 100%;
    padding: 1.25rem 1.35rem;
    border-radius: var(--radius-card);
    border: 1px solid var(--pico-muted-border-color);
    background: var(--pico-card-background-color);
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
}

.alpine-modal__text {
    margin: 0 0 1rem;
    line-height: 1.45;
}

.alpine-modal__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: flex-end;
}

.alpine-slug-preview {
    margin-top: 0.35rem !important;
}
