/* ═══════════════════════════════════════════════════════════════════════════
   Realms Dashboard – Frontend Styles
   Modern Medieval — Editorial Luxury
   ═══════════════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,400;0,500;0,600;0,700&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;1,9..40,400&display=swap');

/* ── Variables ──────────────────────────────────────────────────────────── */

.realms-dashboard {
    --rd-bg: #f6f2ec;
    --rd-bg-warm: #efe9df;
    --rd-bg-card: #ffffff;
    --rd-bg-card-alt: #faf8f4;
    --rd-bg-inset: #eae4d9;
    --rd-border: #d6cfc3;
    --rd-border-light: #e8e2d8;
    --rd-accent: #8b6914;
    --rd-accent-hover: #a47d1a;
    --rd-accent-subtle: rgba(139, 105, 20, 0.08);
    --rd-accent-muted: #c4a84f;
    --rd-text: #3a3428;
    --rd-text-secondary: #7a7164;
    --rd-text-tertiary: #a09888;
    --rd-text-inverse: #ffffff;
    --rd-shadow-sm: 0 1px 2px rgba(58, 52, 40, 0.06);
    --rd-shadow-md: 0 2px 8px rgba(58, 52, 40, 0.08);
    --rd-shadow-lg: 0 4px 16px rgba(58, 52, 40, 0.1);
    --rd-radius: 6px;
    --rd-radius-lg: 10px;
    --rd-font-display: 'Cormorant Garamond', 'Georgia', serif;
    --rd-font-body: 'DM Sans', 'Helvetica Neue', sans-serif;
    --rd-transition: 0.2s ease;

    font-family: var(--rd-font-body);
    font-size: 14px;
    font-weight: 400;
    color: var(--rd-text);
    background: var(--rd-bg);
    border-radius: var(--rd-radius-lg);
    overflow: hidden;
    max-width: 960px;
    margin: 0 auto;
    border: 1px solid var(--rd-border);
    box-shadow: var(--rd-shadow-lg);
    line-height: 1.5;
    position: relative;
}

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

/* Subtle grain texture overlay */
.realms-dashboard::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
    pointer-events: none;
    z-index: 0;
    border-radius: inherit;
}

.realms-dashboard > * {
    position: relative;
    z-index: 1;
}

/* ── Header ─────────────────────────────────────────────────────────────── */

.realms-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 28px;
    background: var(--rd-bg-card);
    border-bottom: 1px solid var(--rd-border);
    flex-wrap: wrap;
    gap: 16px;
}

.realms-header-left {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.realms-header-identity {
    display: flex;
    align-items: center;
    gap: 14px;
}

.realms-crest {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--rd-accent-subtle);
    border: 1px solid var(--rd-border);
    border-radius: var(--rd-radius);
    color: var(--rd-accent);
    flex-shrink: 0;
}

.realms-crest svg {
    width: 22px;
    height: 22px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.realms-player-name {
    font-family: var(--rd-font-display);
    font-size: 22px;
    font-weight: 600;
    color: var(--rd-text);
    margin: 0;
    line-height: 1.2;
    letter-spacing: -0.01em;
}

.realms-manor-title {
    display: block;
    font-family: var(--rd-font-body);
    font-size: 12px;
    font-weight: 500;
    color: var(--rd-text-tertiary);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    margin-top: 2px;
}

/* ── Game Clock ─────────────────────────────────────────────────────────── */

.realms-game-clock {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--rd-bg-inset);
    border: 1px solid var(--rd-border-light);
    border-radius: var(--rd-radius);
    padding: 6px 14px;
    width: fit-content;
}

.realms-clock-icon {
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.realms-clock-icon svg {
    width: 14px;
    height: 14px;
    stroke: var(--rd-accent);
    fill: none;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.realms-clock-date {
    font-family: var(--rd-font-display);
    font-size: 15px;
    font-weight: 600;
    color: var(--rd-text);
    letter-spacing: 0.01em;
    white-space: nowrap;
}

/* ── Coffers / Resource Bar ─────────────────────────────────────────────── */

.realms-coffers {
    text-align: right;
}

.realms-coffers-label {
    display: block;
    font-family: var(--rd-font-body);
    font-size: 10px;
    font-weight: 600;
    color: var(--rd-text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 8px;
}

.realms-resource-bar {
    display: flex;
    gap: 6px;
}

.realms-resource {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    background: var(--rd-bg-card-alt);
    border: 1px solid var(--rd-border-light);
    border-radius: var(--rd-radius);
    padding: 8px 14px 6px;
    min-width: 72px;
    transition: border-color var(--rd-transition), box-shadow var(--rd-transition);
}

.realms-resource:hover {
    border-color: var(--rd-accent-muted);
    box-shadow: var(--rd-shadow-sm);
}

/* Population resources (Peasants & Nobles) – slightly wider for "X / Y" display */
.realms-resource-population {
    min-width: 82px;
    border-left: 2px solid var(--rd-accent-subtle);
}

.realms-resource-population:hover {
    border-left-color: var(--rd-accent-muted);
}

.realms-res-icon {
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1px;
}

.realms-res-icon svg {
    width: 16px;
    height: 16px;
    stroke: var(--rd-accent);
    fill: none;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.realms-res-val {
    font-family: var(--rd-font-display);
    font-size: 16px;
    font-weight: 700;
    color: var(--rd-text);
    line-height: 1.2;
    white-space: nowrap;
}

/* The "/ total" portion shown after the available count */
.realms-res-total {
    font-size: 12px;
    font-weight: 500;
    color: var(--rd-text-tertiary);
}

.realms-res-name {
    font-size: 9px;
    font-weight: 600;
    color: var(--rd-text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

/* ── Tab Navigation ─────────────────────────────────────────────────────── */

.realms-tab-nav {
    display: flex;
    background: var(--rd-bg-warm);
    border-bottom: 1px solid var(--rd-border);
    padding: 0 20px;
    gap: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.realms-tab-nav::-webkit-scrollbar {
    display: none;
}

.realms-tab-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 20px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--rd-text-secondary);
    font-family: var(--rd-font-body);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--rd-transition);
    white-space: nowrap;
    position: relative;
    letter-spacing: 0.01em;
}

.realms-tab-btn:hover {
    color: var(--rd-text);
    background: rgba(139, 105, 20, 0.03);
}

.realms-tab-btn.realms-tab-active {
    color: var(--rd-accent);
    border-bottom-color: var(--rd-accent);
    font-weight: 600;
}

.realms-tab-icon {
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.65;
}

.realms-tab-btn.realms-tab-active .realms-tab-icon {
    opacity: 1;
}

.realms-tab-icon svg {
    width: 15px;
    height: 15px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.realms-tab-label {
    letter-spacing: 0.01em;
}

/* ── Tab Panels ─────────────────────────────────────────────────────────── */

.realms-tab-panels {
    min-height: 420px;
    background: var(--rd-bg);
}

.realms-tab-panel {
    display: none;
    padding: 28px;
    animation: realmsFadeIn 0.25s ease;
}

.realms-tab-panel.realms-panel-active {
    display: block;
}

@keyframes realmsFadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.realms-tab-content {
    font-size: 15px;
    line-height: 1.7;
    color: var(--rd-text-secondary);
}

.realms-tab-content h3 {
    font-family: var(--rd-font-display);
    font-size: 20px;
    font-weight: 600;
    color: var(--rd-text);
    margin: 0 0 12px;
    letter-spacing: -0.01em;
}

.realms-tab-content p {
    margin: 0 0 14px;
}

.realms-realm-news {
    max-width: 640px;
}

.realms-news-placeholder,
.realms-coming-soon {
    color: var(--rd-text-tertiary);
    font-style: italic;
    padding: 16px 0;
    font-size: 14px;
}

/* ── Manor Image ────────────────────────────────────────────────────────── */

.realms-manor-image-wrap {
    text-align: center;
    margin-bottom: 28px;
    padding: 20px;
    background: var(--rd-bg-card);
    border: 1px solid var(--rd-border-light);
    border-radius: var(--rd-radius-lg);
    box-shadow: var(--rd-shadow-sm);
}

.realms-manor-image {
    max-width: 100%;
    height: auto;
    max-height: 380px;
    border-radius: var(--rd-radius);
    display: block;
    margin: 0 auto;
    box-shadow: var(--rd-shadow-md);
}

.realms-manor-caption {
    margin-top: 14px;
    font-family: var(--rd-font-display);
    font-size: 14px;
    font-weight: 500;
    color: var(--rd-text-tertiary);
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.realms-manor-placeholder {
    min-height: 260px;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        linear-gradient(135deg, var(--rd-bg-card) 0%, var(--rd-bg-card-alt) 100%);
}

.realms-manor-placeholder-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    color: var(--rd-text-tertiary);
    font-family: var(--rd-font-display);
    font-size: 16px;
    font-weight: 500;
}

.realms-manor-placeholder-icon {
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--rd-accent-subtle);
    border-radius: 50%;
    opacity: 0.6;
}

.realms-manor-placeholder-icon svg {
    width: 28px;
    height: 28px;
    stroke: var(--rd-accent);
    fill: none;
    stroke-width: 1.5;
}

/* ── Login Prompt ───────────────────────────────────────────────────────── */

.realms-login-prompt {
    background: #ffffff;
    border: 1px solid #d6cfc3;
    border-radius: 10px;
    max-width: 420px;
    margin: 48px auto;
    padding: 48px 36px;
    text-align: center;
    font-family: 'DM Sans', sans-serif;
    box-shadow: 0 4px 16px rgba(58, 52, 40, 0.1);
}

.realms-login-inner {
    color: #3a3428;
}

.realms-login-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(139, 105, 20, 0.08);
    border-radius: 50%;
}

.realms-login-icon svg {
    width: 28px;
    height: 28px;
    stroke: #8b6914;
    fill: none;
    stroke-width: 1.5;
}

.realms-login-inner h2 {
    font-family: 'Cormorant Garamond', serif;
    font-size: 26px;
    font-weight: 600;
    color: #3a3428;
    margin: 0 0 6px;
    letter-spacing: -0.01em;
}

.realms-login-inner p {
    color: #7a7164;
    font-size: 14px;
    margin: 0 0 28px;
    font-weight: 400;
}

.realms-login-btn {
    display: inline-block;
    padding: 11px 32px;
    background: #8b6914;
    color: #ffffff !important;
    font-family: 'DM Sans', sans-serif;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none !important;
    border-radius: 6px;
    border: none;
    letter-spacing: 0.03em;
    transition: all 0.2s ease;
}

.realms-login-btn:hover {
    background: #a47d1a;
    box-shadow: 0 2px 8px rgba(139, 105, 20, 0.25);
    transform: translateY(-1px);
}

/* ── Responsive ─────────────────────────────────────────────────────────── */

@media screen and (max-width: 680px) {
    .realms-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 14px;
        padding: 16px 20px;
    }
    .realms-header-left {
        width: 100%;
    }
    .realms-coffers {
        text-align: left;
        width: 100%;
    }
    .realms-resource-bar {
        flex-wrap: wrap;
    }
    .realms-resource {
        min-width: 60px;
        padding: 6px 10px 5px;
    }
    .realms-resource-population {
        min-width: 70px;
    }
    .realms-player-name {
        font-size: 20px;
    }
    .realms-tab-nav {
        padding: 0 12px;
    }
    .realms-tab-btn {
        padding: 12px 14px;
        font-size: 12px;
    }
    .realms-tab-panel {
        padding: 20px;
    }
    .realms-game-clock {
        padding: 5px 10px;
    }
    .realms-clock-date {
        font-size: 13px;
    }
}