/* ── Fonts ── */
@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;600&family=IM+Fell+English:ital@0;1&display=swap');

/* ── Design Tokens ── */
:root {
    --bg:          #0f1a15;
    --surface:     #162318;
    --surface-2:   #1c2e1f;
    --border:      #2e4a35;
    --gold:        #c9a84c;
    --gold-dim:    #7a6830;
    --gold-glow:   rgba(201,168,76,0.10);
    --text:        #d4e8d0;
    --text-muted:  #6a9e78;
    --accent:      #d4e8d0;
    --font-display: 'Cinzel', serif;
    --font-body:    'IM Fell English', serif;
    --transition:   0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
    background-color: var(--bg);
    background-image:
        radial-gradient(ellipse 80% 60% at 50% -10%, rgba(74,124,89,0.12) 0%, transparent 70%),
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
    color: var(--text);
    font-family: var(--font-body);
    font-size: 17px;
    line-height: 1.75;
    min-height: 100vh;
}

/* ── Navbar ── */
.navbar {
    background: rgba(15,26,21,0.96) !important;
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(12px);
    padding: 1rem 1.5rem;
}
.navbar-brand {
    font-family: var(--font-display);
    font-size: 0.85rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--gold) !important;
}
.nav-link {
    font-family: var(--font-display);
    font-size: 0.75rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--text-muted) !important;
    transition: color 0.3s;
    padding: 0.4rem 1rem !important;
    position: relative;
}
.nav-link::after {
    content: '';
    position: absolute;
    bottom: 0; left: 1rem; right: 1rem;
    height: 1px;
    background: var(--gold);
    transform: scaleX(0);
    transition: transform 0.3s;
}
.nav-link:hover { color: var(--gold) !important; }
.nav-link:hover::after { transform: scaleX(1); }
.nav-link.active { color: var(--gold) !important; }
.nav-link.active::after { transform: scaleX(1); }

/* ── Hamburger ── */
.navbar-toggler {
    border: 1px solid var(--gold-dim);
    padding: 0.3rem 0.6rem;
    border-radius: 0;
}
.navbar-toggler:focus { box-shadow: none; outline: none; }
.navbar-toggler-icon {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba(201,168,76,0.9)' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}
.navbar-collapse {
    background: rgba(15,26,21,0.98);
    padding: 0.5rem 0;
}
@media (max-width: 991px) {
    .navbar-collapse {
        border-top: 1px solid var(--border);
        margin-top: 0.5rem;
    }
    .nav-link::after { display: none; }
    .nav-link { padding: 0.6rem 1.25rem !important; }
}
.ornament {
    text-align: center;
    color: var(--gold-dim);
    font-size: 1.2rem;
    letter-spacing: 0.5em;
    margin: 2rem 0;
    opacity: 0.6;
}

/* ── Headings ── */
h1, h2, h3 {
    font-family: var(--font-display);
    font-weight: 400;
    letter-spacing: 0.08em;
    color: var(--text);
}
h1 { font-size: clamp(1.6rem, 4vw, 2.4rem); }
h2 { font-size: clamp(1.1rem, 2.5vw, 1.5rem); color: var(--gold); }
h3 { font-size: 1rem; letter-spacing: 0.12em; color: var(--text-muted); }

p { color: var(--text); }
a { color: var(--gold); text-decoration: none; }
a:hover { color: var(--text); }

/* ── Fade animation ── */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes shimmer {
    0%, 100% { opacity: 0.5; }
    50%       { opacity: 1; }
}

/* ── Intro section ── */
.intro {
    animation: fadeIn 2.5s ease forwards;
    text-align: center;
    padding: 3rem 1rem 2rem;
}
.intro h1 {
    margin-bottom: 0.5rem;
}
.intro .subtitle {
    color: var(--text-muted);
    font-style: italic;
    font-size: 1rem;
    margin-bottom: 2.5rem;
}

/* ── Casting area (button + monograms together) ── */
.casting-area {
    display: flex;
    flex-direction: column;
    align-items: center;
}
.casting-area .btn-oracle {
    margin-bottom: 1.5rem;
}


.btn-oracle {
    font-family: var(--font-display);
    font-size: 0.78rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--gold);
    background: transparent;
    border: 1px solid var(--gold-dim);
    padding: 0.75rem 2.5rem;
    cursor: pointer;
    position: relative;
    transition: all 0.4s;
    margin-bottom: 2rem;
}
.btn-oracle::before {
    content: '';
    position: absolute;
    inset: -4px;
    border: 1px solid var(--gold-dim);
    opacity: 0;
    transition: opacity 0.4s;
}
.btn-oracle:hover {
    background: var(--gold-glow);
    border-color: var(--gold);
    color: var(--gold);
    box-shadow: 0 0 20px var(--gold-glow);
}
.btn-oracle:hover::before { opacity: 0.5; }

/* ── Monogram casting area ── */
.monogram-stack {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 1rem auto;
    width: 100%;
}

/* ── Monogram rows ── */
.monogram-item {
    opacity: 0;
    transition: opacity 0.8s ease;
    height: 38px;
    display: flex;
    align-items: baseline;
    justify-content: center;
    padding-top: 6px;
    width: 100%;
    gap: 0.75rem;
}
.monogram-item.visible { opacity: 1; }

.monogram {
    font-family: 'Lucida Sans Unicode', 'Arial Unicode MS', sans-serif;
    font-size: 1.8rem;
    line-height: 1;
    color: var(--gold);
    width: 2.2rem;
    text-align: center;
}
.monogram-description {
    font-family: var(--font-display);
    font-size: 0.65rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    text-align: left;
    color: var(--text-muted);
    width: 100px;
}

/* ── Hexagram preview cards ── */
.fadable {
    opacity: 0;
    transition: opacity var(--transition);
}
.fadable.visible { opacity: 1; }

.hexagram-card {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 2rem 1.5rem;
    cursor: pointer;
    transition: all 0.4s;
    position: relative;
    width: 180px;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.hexagram-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--gold-glow);
    opacity: 0;
    transition: opacity 0.4s;
}
.hexagram-card:hover {
    border-color: var(--gold-dim);
    transform: translateY(-3px);
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.hexagram-card:hover::before { opacity: 1; }

.symbol {
    font-family: 'Lucida Sans Unicode', 'Arial Unicode MS', sans-serif;
    font-size: 3.5rem;
    line-height: 1;
    color: var(--gold);
    display: block;
    margin-bottom: 0.5rem;
}
.name {
    font-family: var(--font-display);
    font-size: 0.8rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-muted);
}

/* ── Transition arrow ── */
.transition-text {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding-top: 2rem; /* match card padding so arrow sits beside the symbols */
    color: var(--text-muted);
    font-style: italic;
    font-size: 0.9rem;
    gap: 0.5rem;
}
.transition-text .arrow {
    font-size: 1.5rem;
    color: var(--gold-dim);
    animation: shimmer 2s ease-in-out infinite;
}

/* ── Hexagram detail panel ── */
.hexagram-detail {
    opacity: 0;
    transition: opacity var(--transition);
    border-top: 1px solid var(--border);
    margin-top: 3rem;
    padding-top: 3rem;
}
.hexagram-detail.visible { opacity: 1; }

.hexagram-detail .symbol { font-size: 5rem; margin-bottom: 0.5rem; }
.hexagram-detail .name {
    font-family: var(--font-display);
    font-size: 1.1rem;
    letter-spacing: 0.15em;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 2rem;
}

.judgment {
    font-style: italic;
    color: var(--text);
    max-width: 60ch;
    margin: 0 auto 2.5rem;
    line-height: 1.9;
    font-size: 1.05rem;
    border-left: 2px solid var(--gold-dim);
    padding-left: 1.25rem;
    text-align: left;
}

.section-label {
    font-family: var(--font-display);
    font-size: 0.65rem;
    letter-spacing: 0.25em;
    text-transform: uppercase;
    color: var(--gold-dim);
    margin-bottom: 1.5rem;
    display: block;
}

/* ── Trigrams ── */
.trigram {
    margin: 0.5rem 0;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.75rem;
    text-align: left;
}
.trigrams-block {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    margin: 0 auto 1rem;
}
.trigram .figure {
    font-family: 'Lucida Sans Unicode', 'Arial Unicode MS', sans-serif;
    font-size: 1.8rem;
    color: var(--gold);
    margin: 0;
    line-height: 1;
}
.trigram .image_and_attributes {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-style: italic;
    margin: 0;
    line-height: 1.5;
}

.image {
    color: var(--text-muted);
    font-style: italic;
    font-size: 0.95rem;
    max-width: 55ch;
    margin: 1.5rem auto 2.5rem;
}

/* ── Lines ── */
.lines { max-width: 60ch; margin: 0 auto; text-align: left; }
.lines p { color: var(--text); font-size: 0.95rem; line-height: 1.8; margin-bottom: 0.25rem; }
.lines p b {
    font-family: var(--font-display);
    font-size: 0.7rem;
    letter-spacing: 0.15em;
    color: var(--gold-dim);
    display: block;
    margin-top: 1.25rem;
    text-transform: uppercase;
}

table.hex-grid .btn-link {
    text-decoration: none !important;
    color: inherit;
    box-shadow: none !important;
    display: flex;
    width: 100%;
    height: 100%;
    align-items: flex-start;
    justify-content: center;
    padding: 0;
}
table.hex-grid .btn-link:hover,
table.hex-grid .btn-link:focus {
    text-decoration: none !important;
    color: inherit;
    box-shadow: none !important;
    outline: none;
}
#instruction {
    font-family: var(--font-display);
    font-size: 0.68rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-top: 2rem;
}

/* ── Browse table ── */
.hexagram-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
table.hex-grid {
    border-collapse: separate;
    border-spacing: 3px;
    width: 100%;
    table-layout: fixed;
}
table.hex-grid th,
table.hex-grid td {
    width: 11.1%;
}
table.hex-grid th:first-child,
table.hex-grid td:first-child {
    width: 4%;
}
table.hex-grid th {
    font-family: 'Lucida Sans Unicode', 'Arial Unicode MS', sans-serif;
    font-size: 1.6rem;
    color: var(--gold-dim);
    text-align: center;
    padding: 0.5rem;
    background: transparent;
    border: none;
}
table.hex-grid td {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 0;
    transition: all 0.25s;
    vertical-align: top;
}
table.hex-grid td:hover {
    background: var(--surface-2);
    border-color: var(--gold-dim);
    transform: scale(1.04);
    z-index: 2;
    position: relative;
    box-shadow: 0 4px 20px rgba(0,0,0,0.6);
}
.hexagram-cell {
    text-align: center;
    padding: 0.6rem 0.4rem;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
}
.hexagram-cell .symbol {
    font-size: 1.6rem;
    color: var(--gold);
    display: block;
    line-height: 1;
    margin: 0 0 0.25rem 0;
    padding: 0;
}
.hexagram-cell .name {
    font-family: var(--font-display);
    font-size: 0.52rem;
    letter-spacing: 0.07em;
    color: var(--text-muted);
    text-transform: uppercase;
    line-height: 1.3;
    margin: 0;
    padding: 0;
    word-break: break-word;
    width: 100%;
}

/* ── Modal ── */
.modal-content {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 0;
}
.modal-header {
    border-bottom: 1px solid var(--border);
    padding: 1.25rem 1.5rem;
}
.modal-title {
    font-family: var(--font-display);
    font-size: 0.75rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--gold);
}
.modal-footer {
    border-top: 1px solid var(--border);
}
.btn-close { filter: invert(1) opacity(0.4); }
.btn-close:hover { filter: invert(1) opacity(0.9); }
.btn-secondary {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-family: var(--font-display);
    font-size: 0.7rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    border-radius: 0;
    transition: all 0.3s;
}
.btn-secondary:hover {
    background: var(--gold-glow);
    border-color: var(--gold-dim);
    color: var(--gold);
}

/* ── Resources page ── */
.resources-section {
    max-width: 680px;
    margin: 0 auto;
    padding: 3rem 1rem;
}
.resources-section h3 {
    font-family: var(--font-display);
    font-size: 0.72rem;
    letter-spacing: 0.25em;
    text-transform: uppercase;
    color: var(--gold-dim);
    margin-top: 2.5rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}
.resources-section p {
    color: var(--text-muted);
    font-size: 0.98rem;
    line-height: 1.9;
}
.resources-section a {
    color: var(--gold);
    border-bottom: 1px solid var(--gold-dim);
    transition: color 0.2s, border-color 0.2s;
}
.resources-section a:hover {
    color: var(--text);
    border-color: var(--text);
}

/* ── Page wrapper ── */
.page-content {
    max-width: 960px;
    margin: 0 auto;
    padding: 2rem 1.5rem 5rem;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); }
::-webkit-scrollbar-thumb:hover { background: var(--gold-dim); }