/* =========================================================
   ForYOU NEWS — Account Dashboard
   Desktop: profile + account column on the left, reading
   activity and the newsroom on the right.
   Phones: one column, most-used things first.
   ========================================================= */


/* =========================================================
   TOKENS
   ========================================================= */

:root {
    --brown: #412e03;
    --brown-dark: #2c1f02;
    --gold: #d89b00;
    --gold-dark: #a87700;
    --gold-soft: #fdf6e3;

    --bg: #fafafa;
    --white: #ffffff;
    --line: #e6e6e3;
    --line-soft: #efefec;

    --text: #1f1c16;
    --text-soft: #5f5c55;
    --muted: #8a877f;

    --red: #b42318;
    --green: #177245;

    --radius: 8px;
}


/* =========================================================
   GLOBAL
   ========================================================= */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

[hidden] {
    display: none !important;
}

html {
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;

    background: var(--bg);
    color: var(--text);

    font-family:
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        Roboto,
        Helvetica,
        Arial,
        sans-serif;
    line-height: 1.5;
}

a {
    color: inherit;
    text-decoration: none;
}

button {
    font: inherit;
}

button:focus-visible,
a:focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: 3px;
}


/* =========================================================
   HEADER
   [ < Back to News ]      DASHBOARD      [ logo ]
   ========================================================= */

.account-header {
    position: sticky;
    top: 0;
    z-index: 100;

    width: 100%;

    background: var(--white);
    border-bottom: 1px solid var(--line);
}

.account-header-inner {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 16px;

    width: min(1200px, calc(100% - 40px));
    min-height: 64px;
    margin: 0 auto;
}

/* Back to News: no background, just a hover */
.header-back {
    justify-self: start;

    display: inline-flex;
    align-items: center;
    gap: 8px;

    padding: 8px 4px;

    color: var(--brown);

    font-size: 14px;
    font-weight: 600;

    transition: color 0.2s ease;
}

.header-back svg {
    flex: 0 0 auto;

    width: 20px;
    height: 20px;

    fill: none;
    stroke: currentColor;
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;

    transition: transform 0.2s ease;
}

.header-back:hover {
    color: var(--gold-dark);
}

.header-back:hover svg {
    transform: translateX(-3px);
}

.header-back-short {
    display: none;
}

/* The page name, half visible */
.header-title {
    justify-self: center;

    color: var(--brown);
    opacity: 0.5;

    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.28em;
    text-transform: uppercase;

    white-space: nowrap;
    user-select: none;
}

/* Logo: back to the home page */
.header-home {
    justify-self: end;

    display: inline-flex;
    align-items: center;

    padding: 4px;

    transition: opacity 0.2s ease, transform 0.2s ease;
}

.header-home:hover {
    opacity: 0.8;
    transform: scale(1.05);
}

.account-logo {
    display: block;

    width: 42px;
    height: 42px;

    object-fit: contain;
}


/* =========================================================
   MAIN + WELCOME
   ========================================================= */

.account-main {
    padding: 28px 0 56px;
}

.account-container {
    width: min(1200px, calc(100% - 40px));
    margin: 0 auto;
}

.account-welcome {
    margin-bottom: 22px;
}

.account-eyebrow,
.card-eyebrow {
    margin-bottom: 4px;

    color: var(--gold-dark);

    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.account-welcome h1 {
    color: var(--text);

    font-size: 22px;
    font-weight: 600;
    line-height: 1.3;
    letter-spacing: -0.2px;
}

#user-name {
    color: var(--brown);
    font-weight: 700;
}

.account-welcome-text {
    margin-top: 4px;

    color: var(--text-soft);

    font-size: 14px;
}


/* =========================================================
   LAYOUT
   ========================================================= */

.dashboard-layout {
    display: grid;
    grid-template-columns: 300px minmax(0, 1fr);
    align-items: start;
    gap: 20px;
}

.dash-side,
.dash-content {
    display: grid;
    gap: 16px;

    min-width: 0;
}


/* =========================================================
   CARDS
   ========================================================= */

.dashboard-card {
    padding: 18px;

    background: var(--white);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.dashboard-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
}

.dashboard-card h2 {
    color: var(--text);

    font-size: 16px;
    font-weight: 700;
    line-height: 1.3;
}

.dashboard-card-description {
    margin-top: 6px;

    color: var(--text-soft);

    font-size: 13px;
}

.settings-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    width: 100%;
    min-height: 38px;
    margin-top: 14px;
    padding: 0 14px;

    background: var(--white);
    border: 1px solid #d6d4cf;
    border-radius: 6px;

    color: var(--brown);

    font-size: 13px;
    font-weight: 600;

    cursor: pointer;

    transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}

.settings-button:hover {
    border-color: var(--brown);
    background: var(--gold-soft);
}


/* =========================================================
   PROFILE CARD
   ========================================================= */

.profile-card {
    display: grid;
    justify-items: center;
    gap: 12px;

    padding: 22px 18px 18px;

    background: var(--white);
    border: 1px solid var(--line);
    border-radius: var(--radius);

    text-align: center;
}

.profile-avatar {
    display: flex;
    align-items: center;
    justify-content: center;

    width: 76px;
    height: 76px;

    overflow: hidden;

    background: #f1efe9;
    border: 2px solid var(--line);
    border-radius: 50%;

    color: var(--muted);

    font-size: 28px;
}

.profile-avatar img {
    display: block;

    width: 100%;
    height: 100%;

    object-fit: cover;
}

.profile-avatar-initials {
    color: var(--brown);

    font-size: 24px;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.profile-content {
    min-width: 0;
    width: 100%;
}

.profile-content h2 {
    color: var(--text);

    font-size: 17px;
    font-weight: 700;
    line-height: 1.3;

    overflow-wrap: anywhere;
}

.profile-email-display {
    margin-top: 2px;

    color: var(--text-soft);

    font-size: 13px;

    overflow-wrap: anywhere;
}

/* Edit profile and Log out, side by side */
.profile-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;

    width: 100%;
    margin-top: 4px;
}

.profile-actions .settings-button {
    margin-top: 0;
}

.logout-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    min-height: 38px;
    padding: 0 14px;

    background: var(--white);
    border: 1px solid #d6d4cf;
    border-radius: 6px;

    color: var(--text-soft);

    font-size: 13px;
    font-weight: 600;

    cursor: pointer;

    transition: border-color 0.2s ease, color 0.2s ease;
}

.logout-button:hover {
    border-color: var(--red);
    color: var(--red);
}

.logout-button:disabled {
    opacity: 0.6;
    cursor: wait;
}


/* =========================================================
   ACCOUNT SETTINGS
   ========================================================= */

.account-details {
    margin-top: 12px;

    border-top: 1px solid var(--line-soft);
}

.account-detail {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;

    padding: 10px 0;

    border-bottom: 1px solid var(--line-soft);
}

.account-detail span {
    color: var(--muted);

    font-size: 12.5px;
}

.account-detail strong {
    max-width: 70%;

    color: var(--text);

    font-size: 12.5px;
    font-weight: 600;
    text-align: right;

    overflow-wrap: anywhere;
}


/* =========================================================
   NOTIFICATIONS
   ========================================================= */

.notification-heading {
    position: relative;

    display: inline-flex;
    align-items: flex-start;
}

.notification-alert {
    position: absolute;
    top: -2px;
    right: -11px;

    display: none;

    width: 7px;
    height: 7px;

    background: var(--gold);
    border-radius: 50%;
}

.notification-alert.show {
    display: block;
}


/* =========================================================
   NEWSLETTER
   ========================================================= */

.newsletter-status {
    display: flex;
    align-items: center;
    gap: 8px;

    margin-top: 12px;
    padding: 10px 12px;

    background: var(--bg);
    border: 1px solid var(--line-soft);
    border-radius: 6px;

    color: var(--text-soft);

    font-size: 12.5px;
}

.status-dot {
    flex-shrink: 0;

    width: 8px;
    height: 8px;

    background: #bdbab3;
    border-radius: 50%;
}

.status-dot.active {
    background: var(--green);
}


/* =========================================================
   WRITER INVITE
   ========================================================= */

.writer-invite-card {
    border-color: #e5c66d;
    background: #fffdf6;
}

.writer-invite-card .settings-button {
    width: auto;
    padding: 0 20px;

    background: var(--brown);
    border-color: var(--brown);

    color: var(--white);
}

.writer-invite-card .settings-button:hover {
    background: var(--brown-dark);
    border-color: var(--brown-dark);
}

.writer-invite-message {
    margin-top: 10px;

    font-size: 12.5px;
}

.writer-invite-message.success { color: var(--green); }
.writer-invite-message.error { color: var(--red); }


/* =========================================================
   OVERVIEW (numbers)
   ========================================================= */

.account-overview {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.overview-card {
    display: grid;
    gap: 4px;

    padding: 14px 16px;

    background: var(--white);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.overview-label {
    overflow: hidden;

    color: var(--muted);

    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.overview-card strong {
    color: var(--text);

    font-size: 24px;
    font-weight: 700;
    line-height: 1.1;
}


/* =========================================================
   SAVED ARTICLES / READING HISTORY
   ========================================================= */

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.saved-articles-card,
.reading-history-card {
    position: relative;
}

.card-toggle-button {
    flex: 0 0 auto;

    display: flex;
    align-items: center;
    justify-content: center;

    width: 32px;
    height: 32px;

    background: var(--white);
    border: 1px solid #d6d4cf;
    border-radius: 6px;

    color: var(--brown);

    cursor: pointer;

    transition: border-color 0.2s ease;
}

.card-toggle-button:hover {
    border-color: var(--brown);
}

.card-toggle-chevron {
    width: 16px;
    height: 16px;

    fill: none;
    stroke: currentColor;
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;

    transition: transform 0.25s ease;
}

.card-toggle-button[aria-expanded="true"] .card-toggle-chevron {
    transform: rotate(180deg);
}

/* The list drops down over the page below (closed by default) */
#saved-articles,
#reading-history {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 40;

    display: flex;
    flex-direction: column;
    align-items: stretch;

    min-height: 0;
    max-height: 0;
    margin-top: 6px;
    padding: 12px;

    overflow: hidden;

    background: var(--white);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 16px 32px rgba(0, 0, 0, 0.12);

    opacity: 0;
    transform: translateY(-6px);
    pointer-events: none;

    transition:
        max-height 0.3s ease,
        opacity 0.2s ease,
        transform 0.28s ease;
}

.saved-articles-card.is-open #saved-articles,
.reading-history-card.is-open #reading-history {
    max-height: 440px;

    overflow-y: auto;

    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.empty-state {
    width: 100%;
    padding: 18px 12px;

    text-align: center;
}

.empty-state h3 {
    color: var(--text);

    font-size: 14.5px;
    font-weight: 700;
}

.empty-state p {
    max-width: 320px;
    margin: 4px auto 14px;

    color: var(--muted);

    font-size: 12.5px;
}

.dashboard-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    min-height: 36px;
    padding: 0 16px;

    background: var(--brown);
    border-radius: 6px;

    color: var(--white);

    font-size: 12.5px;
    font-weight: 600;

    transition: background 0.2s ease;
}

.dashboard-action:hover {
    background: var(--brown-dark);
}

.saved-items-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.saved-item {
    position: relative;

    display: flex;
    align-items: center;
    gap: 12px;

    padding: 10px;

    background: var(--bg);
    border: 1px solid var(--line-soft);
    border-radius: 6px;
}

.saved-item-image {
    flex: 0 0 auto;
    display: block;

    width: 52px;
    height: 52px;

    overflow: hidden;

    background: #ecebe6;
}

.saved-item-image img {
    display: block;

    width: 100%;
    height: 100%;

    object-fit: cover;
}

.saved-item-image-placeholder {
    display: block;

    width: 100%;
    height: 100%;
}

.saved-item-content {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 2px;

    min-width: 0;
    padding-right: 26px;
}

.saved-item-title {
    display: -webkit-box;
    overflow: hidden;

    color: var(--text);

    font-size: 13px;
    font-weight: 600;
    line-height: 1.35;

    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.saved-item-title:hover {
    color: var(--gold-dark);
}

.saved-item-meta {
    color: var(--muted);

    font-size: 11px;
}

.saved-item-remove {
    position: absolute;
    top: 6px;
    right: 6px;

    display: flex;
    align-items: center;
    justify-content: center;

    width: 22px;
    height: 22px;

    background: transparent;
    border: 0;
    border-radius: 50%;

    color: #9b988f;

    font-size: 16px;
    line-height: 1;

    cursor: pointer;
}

.saved-item-remove:hover {
    background: rgba(180, 35, 24, 0.08);
    color: var(--red);
}

.saved-item-remove:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}


/* =========================================================
   NEWSROOM (writers and admins)
   ========================================================= */

.newsroom-section {
    padding: 18px;

    background: var(--white);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.newsroom-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;

    padding-bottom: 14px;

    border-bottom: 1px solid var(--line-soft);
}

.newsroom-header h2 {
    margin: 0 0 4px;

    color: var(--text);

    font-size: 18px;
    font-weight: 700;
    line-height: 1.25;
}

.newsroom-description {
    max-width: 640px;

    color: var(--text-soft);

    font-size: 13px;
}

.newsroom-role-badge {
    flex-shrink: 0;

    padding: 5px 10px;

    background: var(--gold-soft);
    border: 1px solid #e5c66d;
    border-radius: 999px;

    color: var(--gold-dark);

    font-size: 10.5px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.newsroom-workspace {
    margin-top: 18px;
}

.newsroom-workspace + .newsroom-workspace {
    margin-top: 22px;
    padding-top: 18px;

    border-top: 1px solid var(--line-soft);
}

.newsroom-workspace-heading {
    margin-bottom: 10px;
}

/* Shop and Promotions groups inside the admin workspace */
.newsroom-card-grid + .newsroom-workspace-heading {
    margin-top: 26px;
}

.newsroom-workspace-heading h3 {
    margin: 2px 0 2px;

    color: var(--text);

    font-size: 15.5px;
    font-weight: 700;
    line-height: 1.3;
}

.newsroom-workspace-heading p:not(.card-eyebrow) {
    max-width: 640px;

    color: var(--text-soft);

    font-size: 12.5px;
}

.newsroom-section .card-eyebrow {
    margin: 0;

    font-size: 10px;
}

.newsroom-card-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.newsroom-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;

    min-height: 88px;
    padding: 14px;

    background: var(--white);
    border: 1px solid var(--line);
    border-radius: 6px;

    transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.newsroom-card:hover {
    border-color: var(--gold);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
    transform: translateY(-1px);
}

.newsroom-card h3 {
    margin: 0 0 4px;

    color: var(--text);

    font-size: 14.5px;
    font-weight: 700;
    line-height: 1.3;
}

.newsroom-card p {
    color: var(--text-soft);

    font-size: 12.5px;
    line-height: 1.45;
}

.newsroom-card-primary {
    background: #fffdf6;
    border-color: #e5c66d;
}

.newsroom-card-primary:hover {
    border-color: var(--gold-dark);
}


/* =========================================================
   FOOTER
   ========================================================= */

.account-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;

    width: min(1200px, calc(100% - 40px));
    margin: 0 auto;
    padding: 18px 0 26px;

    border-top: 1px solid var(--line);

    color: var(--muted);

    font-size: 12px;
}

.footer-links {
    display: flex;
    gap: 16px;
}

.footer-links a:hover {
    color: var(--gold-dark);
}


/* =========================================================
   LAPTOPS
   ========================================================= */

@media (max-width: 1100px) {

    .newsroom-card-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}


/* =========================================================
   TABLETS AND PHONES: one column, most-used first
   ========================================================= */

@media (max-width: 900px) {

    .dashboard-layout {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 14px;
    }

    .dash-side,
    .dash-content {
        display: contents;
    }

    .account-profile-section  { order: 1; }
    .writer-invite-card       { order: 2; }
    .account-overview         { order: 3; }
    .dashboard-grid           { order: 4; }
    .newsroom-section         { order: 5; }
    .notifications-card       { order: 6; }
    .newsletter-card          { order: 7; }
    .account-settings-card    { order: 8; }

    /* Profile sits in a row on tablets */
    .profile-card {
        grid-template-columns: auto minmax(0, 1fr) auto;
        justify-items: start;
        align-items: center;
        gap: 16px;

        text-align: left;
    }

    .profile-actions {
        width: auto;
        margin-top: 0;
    }
}


@media (max-width: 640px) {

    .account-header-inner,
    .account-container,
    .account-footer {
        width: calc(100% - 28px);
    }

    .account-header-inner {
        min-height: 58px;
        gap: 8px;
    }

    .header-back-long {
        display: none;
    }

    .header-back-short {
        display: inline;
    }

    .header-title {
        font-size: 12px;
        letter-spacing: 0.22em;
    }

    .account-logo {
        width: 36px;
        height: 36px;
    }

    .account-main {
        padding: 20px 0 40px;
    }

    .account-welcome {
        margin-bottom: 16px;
    }

    .account-welcome h1 {
        font-size: 19px;
    }

    .account-welcome-text {
        font-size: 13px;
    }

    /* Profile stacks, buttons stay side by side */
    .profile-card {
        grid-template-columns: 1fr;
        justify-items: center;

        padding: 18px 14px 14px;

        text-align: center;
    }

    .profile-actions {
        width: 100%;
    }

    .profile-avatar {
        width: 68px;
        height: 68px;
    }

    .account-overview {
        gap: 8px;
    }

    .overview-card {
        padding: 10px;
    }

    .overview-label {
        font-size: 10px;
        line-height: 1.25;
        letter-spacing: 0.04em;
        white-space: normal;
    }

    .overview-card strong {
        font-size: 19px;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .dashboard-card,
    .newsroom-section {
        padding: 15px;
    }

    .saved-articles-card.is-open #saved-articles,
    .reading-history-card.is-open #reading-history {
        max-height: 340px;
    }

    .newsroom-header {
        flex-direction: column;
        gap: 8px;
    }

    .newsroom-card-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .newsroom-card {
        min-height: 0;
        padding: 12px;
    }

    .account-footer {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
}


@media (max-width: 380px) {

    .header-title {
        letter-spacing: 0.16em;
    }

    .overview-label {
        font-size: 9px;
    }

    .overview-card strong {
        font-size: 17px;
    }
}
