/*==============================================================================
    VARIABLER
==============================================================================*/

/* ------------------------------- FARGER ------------------------------------- */

:root {
    --background: #f7f3eb;
    --text: #2f2f2f;

    --link: #b9912c;
    --link-hover: #96741f;

    --border: #ded6c7;

    --text-muted: #777;
    --text-subtle: #888;

    --card-background: transparent;
}

/* ------------------------------- TYPOGRAFI ---------------------------------- */

:root {
    --font-body: "Crimson Pro", serif;
    --font-heading: "Cormorant Garamond", serif;
}

/* ------------------------------- SPACING ------------------------------------ */

:root {
    --content-width: 700px;
    --wide-content-width: 900px;
    --page-padding: 2rem;
}


/*==============================================================================
    GENERELT
==============================================================================*/

/* ------------------------------- RESET -------------------------------------- */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ------------------------------- BODY --------------------------------------- */

body {
    background: var(--background);
    color: var(--text);

    font-family: var(--font-body);
    font-size: 1.1rem;
    line-height: 1.9;
}

/* ------------------------------- MAIN --------------------------------------- */

main {
    width: 100%;
    max-width: var(--content-width);

    margin: 0 auto;
    padding: 0 var(--page-padding) 3rem;
}

/* ------------------------------- TYPOGRAFI --------------------------------- */

h1,
h2,
h3 {
    font-family: var(--font-heading);
}

/* ------------------------------- LENKER ------------------------------------ */

a {
    color: var(--link);
}

a:hover {
    color: var(--link-hover);
    letter-spacing: 0.2em;
}

/*==============================================================================
    HEADER
==============================================================================*/

header {
    margin: 4rem 0 1rem;
    text-align: center;
}

.theme-toggle {
    display: block;

    margin: 1rem auto 0;
    padding: 0;

    background: transparent;
    border: none;

    color: var(--text);

    font-family: inherit;
    font-size: 1.3rem;
    line-height: 1;

    cursor: pointer;
}

.theme-toggle:hover {
    color: var(--link);
}

.theme-toggle:focus-visible {
    outline: 1px solid var(--link);
    outline-offset: 0.4rem;
}


/*==============================================================================
    ADMIN HEADER
==============================================================================*/

.admin-header {
    position: relative;
    text-align: center;
    margin-bottom: 1.5rem;
}

.site-name {
    color: var(--link);
    font-family: inherit;
    font-size: clamp(2rem, 7vw, 3.5rem);
    font-weight: 400;
    line-height: 1;
    text-decoration: none;
    letter-spacing: 0.08em;
}

.site-name:hover,
.site-name:focus-visible {
    color: var(--link);
    letter-spacing: 0.2em;
}

.admin-label {
    margin: 0.75rem 0 0;
    color: var(--text-muted);
    font-size: 2rem;
    letter-spacing: 0.12em;
    text-transform: lowercase;
}


/*==============================================================================
    ADMIN NAVIGASJON
==============================================================================*/

.admin-nav {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.65rem;

    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.admin-nav a,
.admin-nav button {
    border: 0;
    padding: 0;
    background: none;
    color: var(--text-muted);
    font: inherit;
    text-decoration: none;
    cursor: pointer;
}

.admin-nav a:hover,
.admin-nav button:hover,
.admin-nav a:focus-visible,
.admin-nav button:focus-visible {
    color: var(--link);
}

.admin-nav a[aria-current="page"] {
    color: var(--text);
    font-weight: 600;
}


/*==============================================================================
    DIVIDER
==============================================================================*/

.page-divider {
    display: flex;
    align-items: center;
    gap: 1rem;

    max-width: var(--content-width);
    margin: 4rem auto;

    color: var(--border);
}

.page-divider::before,
.page-divider::after {
    content: "";

    flex: 1;

    border-top: 1px solid var(--border);
}

.page-divider span {
    margin: 0 1.25rem;

    color: var(--link);
}


/*==============================================================================
    ADMIN DIVIDER
==============================================================================*/

.admin-divider {
    display: flex;
    align-items: center;
    gap: 1rem;

    width: 100%;
    max-width: var(--content-width);
    margin: 1.5rem auto 0;

    color: var(--border);
}

.admin-divider::before,
.admin-divider::after {
    content: "";
    flex: 1;
    border-top: 1px solid var(--border);
}

.admin-divider span {
    margin: 0 1.25rem;
    color: var(--link);
}


/*==============================================================================
    SIDE
==============================================================================*/

.admin-page {
    width: min(100% - 2rem, 50rem);
    margin-inline: auto;
}

.admin-panel {
    border: 0;
    padding: 0;
    text-align: center;
}

.admin-panel h1 {
    margin-bottom: 0.75;
}

.admin-heading {
    margin-bottom: 1rem;
    margin-top: 1rem;
    text-align: center;
}

.admin-heading h1 {
    margin-bottom: 1rem;
    margin-top: 1rem;
    text-align: center;
}

.admin-intro {
    margin-bottom: 1rem;
    margin-top: 1rem;
    text-align: center;
    color: var(--text-muted);
}



/*==============================================================================
    DASHBOARD
==============================================================================*/

.dashboard-actions {
    display: grid;
    gap: 1rem;
}

.dashboard-action {
    display: block;
    width: 100%;
    padding: 1rem 0;
    border: 0;
    background: transparent;
    color: var(--text);
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    font: inherit;
}

.dashboard-action:hover,
.dashboard-action:focus-visible {
    color: var(--link);
}

.dashboard-action:hover p,
.dashboard-action:hover .dashboard-action-text,
.dashboard-action:focus-visible p,
.dashboard-action:focus-visible .dashboard-action-text {
    color: var(--link);
}

.dashboard-action h2,
.dashboard-action-title {
    display: block;
    margin: 0 0 0.5rem;
    font-size: 1.2rem;
    font-weight: 600;
}

.dashboard-action p,
.dashboard-action-text {
    display: block;
    margin: 0;
    color: var(--text-muted);
}

.dashboard-logout {
    appearance: none;
}


/*==============================================================================
    FOOTER
==============================================================================*/

footer {
    margin-top: 8rem;
    padding: 3rem var(--page-padding);

    text-align: center;
    font-size: 1rem;
}


/*==============================================================================
    MØRK MODUS
==============================================================================*/

[data-theme="dark"] {
    --background: #1d1b19;
    --text: #e8e1d6;

    --link: #d5b54c;
    --link-hover: #e5c96f;

    --border: #48423b;

    --text-muted: #b8afa3;
    --text-subtle: #9f968c;

    --card-background: transparent;
}


/*==============================================================================
    SKJEMA
==============================================================================*/

#new-story-form {
    width: 100%;
    max-width: 42rem;
    margin: 0 auto;
}

.form-field {
    margin-bottom: 2rem;
    text-align: center;
}

.form-field label,
.form-field legend {
    display: block;
    margin-bottom: 0.6rem;
}

.field-title {
    display: block;
    margin-bottom: 0.6rem;

    color: var(--link);
    font-size: 2rem;
    font-weight: 500;
    text-align: center;
}

.form-field input[type="text"],
.form-field input[type="password"],
.form-field input[type="number"],
.form-field select,
.form-field textarea {
    width: 100%;
    border: 1px solid var(--border);
    background: var(--background);
    color: var(--text);
    padding: 0.85rem 1rem;
    font: inherit;
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
    border-color: var(--link);
    outline: none;
}

.form-field textarea {
    resize: vertical;
}

.field-help {
    margin-top: 0.5rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.summary-options {
    margin: 0 0 2rem;
    border: 0;
    padding: 0;
    text-align: center;
}

#automatic-summary-preview {
    margin-top: 1rem;
    padding: 1rem;

    border: 1px solid var(--border);
    border-left: 4px solid var(--text-muted);

    background: color-mix(in srgb, var(--background) 92%, var(--text) 8%);

    border-radius: 0.5rem;
    text-align: left;
}

.preview-title {
    margin: 0 0 0.75rem;

    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

#automatic-summary-text {
    margin: 0;

    color: var(--text);
    white-space: pre-wrap;
    line-height: 1.6;
}

.radio-option {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.6rem;
    font-weight: 400;
}

.radio-option input {
    margin: 0;
}


/*==============================================================================
    EDITOR
==============================================================================*/

.editor-toolbar {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.editor-button {
    min-width: 2.75rem;
    min-height: 2.5rem;
    border: 1px solid var(--border);
    background: var(--background);
    color: var(--text);
    cursor: pointer;
    font: inherit;
}

.editor-button:hover,
.editor-button:focus-visible {
    border-color: var(--link);
    color: var(--link);
}

.story-editor {
    min-height: 28rem;
    border: 1px solid var(--border);
    padding: 1.25rem;
    background: var(--background);
    color: var(--text);
    line-height: 1.8;
    outline: none;
}

.story-editor:focus {
    border-color: var(--link);
}

.story-editor:empty::before {
    content: attr(data-placeholder);
    color: var(--text-subtle);
    pointer-events: none;
}

.story-editor p,
.story-editor div {
    margin: 0 0 1.25rem;
}

.story-editor .story-divider {
    width: 3rem;
    margin: 2.5rem auto;
    border: 0;
    border-top: 1px solid var(--border);
}


/*==============================================================================
    HISTORIEINFORMASJON
==============================================================================*/

.story-information-preview {
    margin: 3rem 0;
    padding: 1.5rem 0;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    text-align: center;
}

.story-information-preview h2 {
    color: var(--link);
    margin-bottom: 1.5rem;
    font-size: 1.2rem;
}

.story-information-preview dl {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin: 0;
}

.story-information-preview dl div {
    min-width: 0;
}

.story-information-preview dt {
    color: var(--text-muted);
    font-size: 1rem;
    text-transform: lowercase;
}

.story-information-preview dd {
    margin: 0.35rem 0 0;
    overflow-wrap: anywhere;
}



/*==============================================================================
    SITAT
==============================================================================*/

.preview,
.generated-code {
    margin-top: 2rem;
}

.preview blockquote {
    margin: 0;
    font-size: 1.5rem;
    font-style: italic;
}

.preview cite {
    display: block;
    margin-top: .5rem;
    text-align: right;
}

.generated-code pre {
    padding: 1rem;

    overflow-x: auto;

    border: 1px solid var(--border);

    background: var(--surface);

    white-space: pre-wrap;
}

.quote-preview {
    text-align: center;
}

.quote-preview blockquote,
.quote-preview cite,
.quote-preview p {
    text-align: center;
}


/*==============================================================================
    HANDLINGER
==============================================================================*/

.form-status {
    min-height: 1.5rem;
    margin-bottom: 1rem;
    color: var(--text-muted);
    text-align: center;
}

.form-actions {
    display: flex;
    justify-content: center;
    gap: 1rem;
}

.primary-button {
    border: 1px solid var(--link);
    background: var(--link);
    color: var(--background);
    padding: 0.85rem 1.5rem;
    cursor: pointer;
    font: inherit;
}

.primary-button:hover,
.primary-button:focus-visible {
    border-color: var(--link-hover);
    background: var(--link-hover);
}



/*==============================================================================
    MOBIL
==============================================================================*/

@media (max-width: 600px) {

    .admin-page {
        padding: 2rem 0;
    }

    .admin-panel {
        padding: 1.25rem;
    }

    .editor-toolbar {
        gap: 0.4rem;
    }

    .story-information-preview dl {
        grid-template-columns: 1fr;
    }

    .form-actions {
        justify-content: stretch;
    }

    .primary-button {
        width: 100%;
    }

}