/* --- Nartjieput Merchant's Guild Master Stylesheet --- */
:root {
    --aged-parchment: #e2c99d;
    --dark-wood:      #3e2723;
    --burnt-edge:     #5d4037;
    --guild-gold:     #c5a059;
    --blood-red:      #7b1d1d;
    --ink:            #2c1e1a;
}

/* Base Setup */
body {
    background-color: #1a1a1a;
    background-image: url('https://www.transparenttextures.com/patterns/dark-leather.png');
    color: var(--ink);
    font-family: 'Palatino Linotype', 'Book Antiqua', Palatino, serif;
    margin: 0;
    padding: 15px;
}

/* Main Page Container - The Parchment */
.parchment {
    max-width: 900px;
    margin: 20px auto;
    background-color: var(--aged-parchment);
    background-image: url('https://www.transparenttextures.com/patterns/paper-fibers.png');
    padding: 30px;
    border: 12px solid var(--dark-wood);
    border-image: linear-gradient(to bottom, #5d4037, #3e2723) 1;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.8);
    position: relative;
    min-height: 80vh;
}

/* Typography */
h1, h2, h3 {
    color: var(--blood-red);
    text-transform: uppercase;
    letter-spacing: 1px;
}

h1 {
    font-size: 2.2em;
    text-align: center;
    border-bottom: 2px double var(--burnt-edge);
    padding-bottom: 10px;
}

h2 {
    font-size: 1.5em;
    border-bottom: 1px solid var(--burnt-edge);
    margin-top: 30px;
}

/* Motto / tagline under main title */
.motto {
    text-align: center;
    margin-top: -6px;
    color: var(--burnt-edge);
    font-size: 1.05em;
}

a {
    color: var(--blood-red);
    font-weight: bold;
    text-decoration: none;
}
a:hover { text-decoration: underline; }

/* Navigation / Menu Bar */
.nav-bar {
    text-align: center;
    margin-bottom: 20px;
    padding: 10px;
    background: rgba(62, 39, 35, 0.1);
    border: 1px solid var(--burnt-edge);
}

.nav-bar a {
    margin: 0 15px;
    color: var(--dark-wood);
    text-transform: uppercase;
    font-size: 0.9em;
}

/* Greeting / last-login block */
.greeting-block h2 {
    color: var(--blood-red);
    font-size: 1.4em;
}
.last-login {
    font-size: 0.9em;
    letter-spacing: 0.5px;
}

/* Common Components */
.scroll-box {
    background: #d4b483;
    padding: 15px;
    border: 1px solid #b08d57;
    box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

/* Grids & Cards */
.grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.plaque-card {
    background: var(--dark-wood);
    color: #d7ccc8;
    padding: 20px;
    border: 4px ridge var(--guild-gold);
    text-align: center;

    /* Fade-up entrance (staggered via nth-child below) */
    opacity: 0;
    transform: translateY(12px);
    animation: plaque-rise 0.55s ease-out forwards;
}

/* Staggered delays — 80ms between tiles, up to 6 deep */
.grid-container .plaque-card:nth-child(1) { animation-delay: 0.05s; }
.grid-container .plaque-card:nth-child(2) { animation-delay: 0.13s; }
.grid-container .plaque-card:nth-child(3) { animation-delay: 0.21s; }
.grid-container .plaque-card:nth-child(4) { animation-delay: 0.29s; }
.grid-container .plaque-card:nth-child(5) { animation-delay: 0.37s; }
.grid-container .plaque-card:nth-child(6) { animation-delay: 0.45s; }

@keyframes plaque-rise {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Respect users who prefer no motion */
@media (prefers-reduced-motion: reduce) {
    .plaque-card {
        animation: none;
        opacity: 1;
        transform: none;
    }
}

.plaque-card h3 {
    color: var(--guild-gold);
    margin: 0 0 10px 0;
}

/* Compact stat-tile variant (tighter padding, smaller heading, bigger value) */
.plaque-card.compact {
    padding: 10px 12px;
    border-width: 3px;
}

.plaque-card.compact h3 {
    font-size: 0.85em;
    letter-spacing: 1.5px;
    margin: 0 0 4px 0;
    opacity: 0.9;
}

.plaque-card.compact p {
    margin: 0;
    font-size: 1.4em;
    font-weight: bold;
    color: var(--aged-parchment);
    font-variant-numeric: tabular-nums;
}

/* Colour-coded plaque variants (used on the Investment Value tile) */
.plaque-card.compact.positive {
    border-color: #4d8a3a;                /* mossy green ridge */
    box-shadow: inset 0 0 0 1px rgba(77, 138, 58, 0.4);
}
.plaque-card.compact.positive p { color: #b6e29a; }

.plaque-card.compact.negative {
    border-color: #a23131;                /* heraldic red ridge */
    box-shadow: inset 0 0 0 1px rgba(162, 49, 49, 0.4);
}
.plaque-card.compact.negative p { color: #f1a8a8; }

.plaque-card.compact.neutral p { color: var(--guild-gold); }

/* Trend arrow next to a stat value */
.trend {
    display: inline-block;
    margin-left: 6px;
    font-size: 0.75em;
    vertical-align: middle;
    line-height: 1;
}
.trend.trend-up   { color: #b6e29a; }
.trend.trend-down { color: #f1a8a8; }
.trend.trend-flat { color: var(--guild-gold); opacity: 0.85; }

/* Sparkline */
.sparkline-wrap {
    margin-top: 6px;
    line-height: 0;
    color: var(--guild-gold);
}
.sparkline-wrap.trend-up   { color: #b6e29a; }
.sparkline-wrap.trend-down { color: #f1a8a8; }
.sparkline-wrap.trend-flat { color: var(--guild-gold); opacity: 0.85; }

.sparkline {
    display: inline-block;
    max-width: 100%;
    height: 20px;
}

/* --- Draw-in animation (purely cosmetic) -------------------------
   The polyline starts fully "hidden" by offsetting a long dash
   equal to its dash length, then animates the offset back to 0,
   making the line appear to draw itself across the tile. */
.sparkline polyline {
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
    animation: sparkline-draw 1.4s ease-out 0.2s forwards;
}

@keyframes sparkline-draw {
    to { stroke-dashoffset: 0; }
}

/* Respect users who prefer no motion */
@media (prefers-reduced-motion: reduce) {
    .sparkline polyline {
        animation: none;
        stroke-dashoffset: 0;
    }
}

/* Buttons */
.btn-gold {
    display: inline-block;
    background: var(--guild-gold);
    color: var(--dark-wood) !important;
    padding: 10px 20px;
    text-decoration: none !important;
    font-weight: bold;
    text-transform: uppercase;
    border: 1px solid #000;
    cursor: pointer;
}

.btn-gold:hover { background: #e2c99d; }

/* Ledger Tables */
.ledger-table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
}

.ledger-table th {
    background: var(--burnt-edge);
    color: white;
    padding: 12px;
}
.ledger-table td {
    padding: 12px;
    border-bottom: 1px solid var(--burnt-edge);
    text-align: left;
}
.ledger-table tr:nth-child(even) {
    background: rgba(93, 64, 55, 0.05);
}

/* Wax Seal Utility */
.wax-seal {
    width: 60px;
    height: 60px;
    background: #8e1a1a;
    border-radius: 50%;
    position: absolute;
    bottom: 20px;
    right: 20px;
    border: 2px solid #5d0c0c;
    box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.4);
}

/* Responsive */
@media (max-width: 600px) {
    .parchment { padding: 15px; border-width: 6px; }
    h1 { font-size: 1.6em; }
    .plaque-card.compact p { font-size: 1.2em; }
}