/* assets/css/base.css
   Site-wide reset, color tokens, and the top nav (partials/header.php).
   Loaded on every page before the page's own stylesheet. */

:root {
    --color-bg: #fef2ec;
    --color-surface: #ffffff;
    --color-accent: #f0576a;
    --color-logo: #f0646e;
    --color-text: #1a1a1a;
    --color-text-muted: #6b6b6b;
    --color-border: #ececec;

    /* Shared column width so the nav and the feed cards below it line up
       at the same edges. */
    --content-max-width: 62.5rem;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--color-text);
    background: var(--color-bg);
}

a {
    color: inherit;
}

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

/* ---- Shared page layout ----
   Generic version of what feed.css built for the feed page: a
   nav-width column on the pink background, with content in a white
   card. New pages should reach for these rather than re-deriving the
   width/card logic. */

.page {
    max-width: var(--content-max-width);
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

@media (max-width: 40rem) {
    .page {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
}

.card {
    background: var(--color-surface);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    padding: 1.5rem;
}

/* ---- Flash messages ----
   Session-flash banners (post-redirect success/error notes), sitting
   directly in .page above the .card -- not tied to any one form. */

.flash-success,
.flash-error {
    padding: 0.85rem 1.25rem;
    border-radius: 0.5rem;
    font-weight: 600;
    margin: 0 0 1.5rem;
}

.flash-success {
    background: #eafaf1;
    border: 1px solid #b7e4c7;
    color: #1e7e46;
}

.flash-error {
    background: #fdecec;
    border: 1px solid #f3b9b9;
    color: #8a1f1f;
}

/* ---- Markdown body text (.prose) ----
   Shared by the trip page (body/experiences) and the static pages (Om
   Turen, Hjälp, ...) -- both render Markdown through Markdown.php the
   same way. Each line there is its own <p>, but they read as two
   different things depending on how the writer actually broke the line:
    - a single Enter (no .prose-break class) -- just a wrapped line
      within the same train of thought, indented like the paragraph
      it's part of, with zero extra margin: the gap between it and the
      line before is exactly the line-height, same as a normal wrapped
      line inside one paragraph.
    - a blank line / Enter twice (.prose-break) -- a genuinely new
      paragraph: real space above it, and, like text right after a
      headline, not indented. */

.prose {
    line-height: 1.6;
}

.prose p {
    margin: 0;
    text-indent: 1.5em;
}

.prose p.prose-break {
    margin-top: 1rem;
    text-indent: 0;
}

.prose h1,
.prose h2,
.prose h3 {
    margin: 1.5rem 0 0.75rem;
}

.prose > :first-child {
    margin-top: 0;
}

/* ---- Top nav ---- */

.site-header {
    background: var(--color-surface);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    position: sticky;
    top: 0;
    z-index: 10;
}

.site-header-inner {
    max-width: var(--content-max-width);
    margin: 0 auto;
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
}

.site-logo {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.site-logo svg {
    display: block;
    height: 1.75rem;
    width: auto;
    color: var(--color-logo);
}

.site-nav {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex: 1;
    font-weight: 600;
}

.site-nav a {
    text-decoration: none;
    color: var(--color-accent);
    white-space: nowrap;
}

.site-nav a.active {
    color: var(--color-text);
}

.site-header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* ---- Search ---- */

.site-search {
    display: flex;
    align-items: center;
    background: #f5f5f5;
    border-radius: 999px;
    padding: 0.4rem 0.9rem;
    gap: 0.5rem;
}

.site-search input {
    border: none;
    background: transparent;
    outline: none;
    font-size: 0.9rem;
    width: 6.5rem;
}

.site-search button {
    border: none;
    background: none;
    padding: 0;
    display: flex;
    cursor: pointer;
    color: var(--color-text-muted);
}

.site-search button svg {
    width: 1.1rem;
    height: 1.1rem;
}

/* ---- User menu ---- */

.user-menu {
    position: relative;
}

.user-menu-trigger {
    list-style: none;
    cursor: pointer;
    display: block;
}

.user-menu-trigger::-webkit-details-marker {
    display: none;
}

.user-menu-avatar {
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}

.user-menu-avatar--fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-accent);
    color: #fff;
    font-weight: 700;
    text-transform: uppercase;
}

.user-menu-dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + 0.5rem);
    background: var(--color-surface);
    border-radius: 0.5rem;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    min-width: 10rem;
    padding: 0.4rem;
    display: flex;
    flex-direction: column;
}

.user-menu-dropdown a,
.user-menu-dropdown button {
    text-align: left;
    border: none;
    background: none;
    font: inherit;
    color: var(--color-text);
    text-decoration: none;
    padding: 0.5rem 0.6rem;
    border-radius: 0.35rem;
    cursor: pointer;
}

.user-menu-dropdown a:hover,
.user-menu-dropdown button:hover {
    background: var(--color-bg);
}

.site-login-link {
    text-decoration: none;
    font-weight: 600;
    color: var(--color-accent);
    white-space: nowrap;
}

/* ---- Login dropdown ----
   Same <details>/<summary> approach as .user-menu above -- the login
   form lives right here in the nav instead of on its own page, open
   from wherever the visitor already is. */

.login-menu {
    position: relative;
}

.login-menu-trigger {
    list-style: none;
    cursor: pointer;
    display: block;
}

.login-menu-trigger::-webkit-details-marker {
    display: none;
}

.login-menu-dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + 0.5rem);
    width: 18rem;
    background: var(--color-surface);
    border-radius: 0.5rem;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    padding: 1.25rem;
    z-index: 20;
}

.login-menu-dropdown .errors {
    background: #fdecec;
    border: 1px solid #f3b9b9;
    color: #8a1f1f;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    margin: 0 0 1rem;
    font-size: 0.9rem;
}

.login-menu-dropdown label {
    display: block;
    font-weight: 600;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.login-menu-dropdown input {
    display: block;
    width: 100%;
    margin-top: 0.35rem;
    padding: 0.55rem 0.7rem;
    font: inherit;
    font-weight: 400;
    color: var(--color-text);
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 0.5rem;
    box-sizing: border-box;
}

.login-menu-dropdown input:focus {
    outline: 2px solid var(--color-accent);
    outline-offset: -1px;
}

.login-menu-dropdown > form > button[type="submit"] {
    display: block;
    width: 100%;
    margin-top: 0.25rem;
    padding: 0.65rem 1rem;
    font: inherit;
    font-weight: 700;
    color: #fff;
    background: var(--color-accent);
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
}

.login-menu-dropdown > form > button[type="submit"]:hover {
    background: var(--color-logo);
}

.login-menu-dropdown .resend-form {
    margin: 0 0 1rem;
}

.login-menu-dropdown .resend-form button {
    width: 100%;
    padding: 0.5rem 0.75rem;
    font: inherit;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--color-text);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 0.5rem;
    cursor: pointer;
}

.login-menu-dropdown .resend-form button:hover {
    background: var(--color-bg);
}

.login-menu-links {
    margin: 1rem 0 0;
    padding-top: 1rem;
    border-top: 1px solid var(--color-border);
    text-align: center;
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

.login-menu-links a {
    color: var(--color-accent);
    font-weight: 600;
    text-decoration: none;
}

.login-menu-links a:hover {
    text-decoration: underline;
}

@media (max-width: 40rem) {
    .login-menu-dropdown {
        width: 16rem;
    }
}

/* ---- Mobile nav (hamburger + search icon) ----
   Hidden by default -- the breakpoint below swaps these in for .site-nav
   and the inline search form, which hide at that width. */

.nav-menu,
.mobile-search {
    display: none;
    position: relative;
}

.nav-menu-trigger,
.mobile-search-trigger {
    list-style: none;
    cursor: pointer;
    display: flex;
    color: var(--color-text);
}

.nav-menu-trigger::-webkit-details-marker,
.mobile-search-trigger::-webkit-details-marker {
    display: none;
}

.nav-menu-trigger svg {
    width: 1.8rem;
    height: 1.8rem;
}

.mobile-search-trigger svg {
    width: 1.4rem;
    height: 1.4rem;
}

.nav-menu-dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + 0.5rem);
    background: var(--color-surface);
    border-radius: 0.5rem;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    min-width: 10rem;
    padding: 0.4rem;
    display: flex;
    flex-direction: column;
    z-index: 20;
}

.nav-menu-dropdown a {
    text-decoration: none;
    color: var(--color-accent);
    padding: 0.5rem 0.6rem;
    border-radius: 0.35rem;
    font-weight: 600;
}

.nav-menu-dropdown a.active {
    color: var(--color-text);
}

.nav-menu-dropdown a:hover {
    background: var(--color-bg);
}

.mobile-search-panel {
    position: absolute;
    right: 0;
    top: calc(100% + 0.5rem);
    background: var(--color-surface);
    border-radius: 0.5rem;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    padding: 0.6rem;
    z-index: 20;
}

.mobile-search-panel .site-search {
    width: 12rem;
}

.mobile-search-panel .site-search input {
    flex: 1;
    width: auto;
}

@media (max-width: 40rem) {
    .site-header-inner {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    .site-nav {
        display: none;
    }

    .site-header-actions > .site-search {
        display: none;
    }

    .nav-menu,
    .mobile-search {
        display: block;
    }
}
