/* =============================================================================
   Curious Circle — Ghost theme styles
   ===========================================================================
   Mirrors the design tokens, typography, and surface treatment of
   curiouscircle.com (Next.js / Tailwind). Tokens are kept in sync with
   src/app/globals.css and tailwind.config.ts in the curiouscircle repo.

   Breakpoints (mobile-first):
     sm  ≥ 480px   large phone / small tablet
     md  ≥ 768px   tablet / small laptop
     lg  ≥ 1024px  laptop
     xl  ≥ 1280px  desktop
     2xl ≥ 1536px  wide desktop
   ========================================================================= */

:root {
    /* Brand palette */
    --color-brand-green: #041739;
    --color-brand-cream: #F4EDE1;
    --color-brand-rust:  #C86B4A;
    --color-brand-dark:  #1A1A1A;

    /* Cream-on-dark border tokens */
    --border-cream-soft:   rgba(244, 237, 225, 0.12);
    --border-cream-mid:    rgba(244, 237, 225, 0.20);
    --border-cream-strong: rgba(244, 237, 225, 0.40);

    /* Type stacks */
    --font-display: "Gambarino", "Times New Roman", serif;
    --font-body:    "Gambarino", "Times New Roman", serif;
    --font-mono:    "Courier Prime", ui-monospace, "SFMono-Regular", Menlo, monospace;

    /* Layout columns:
       --read-col  = prose / body text — optimised for ~65-75 chars per line
       --card-col  = postcard header card — wider than prose, narrower than viewport
       --page-x    = horizontal page padding (scales with screen)               */
    --read-col: min(48rem, 100%);
    --card-col: min(56rem, 100%);
    --page-x: 1.25rem;
}

@media (min-width: 480px)  { :root { --page-x: 2rem; } }
@media (min-width: 768px)  { :root { --page-x: 3rem; } }
@media (min-width: 1024px) { :root { --page-x: 5rem; } }
@media (min-width: 1280px) { :root { --page-x: 6rem; } }

/* -----------------------------------------------------------------------------
   Reset & base
   -------------------------------------------------------------------------- */

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

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background-color: var(--color-brand-green);
    color: var(--color-brand-cream);
    font-family: var(--font-body);
    font-weight: 400;
    /* Fluid base type: 16px phone → 18px desktop */
    font-size: clamp(1rem, 0.9rem + 0.5vw, 1.125rem);
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    min-height: 100vh;
    overflow-x: hidden;
}

a { color: var(--color-brand-rust); text-decoration: none; }
a:hover { text-decoration: underline; }

img, video, figure { max-width: 100%; height: auto; display: block; }
figure { margin: 2rem 0; }

/* -----------------------------------------------------------------------------
   Page chrome: grain, binding strip, floating logo + nav
   -------------------------------------------------------------------------- */

.cc-page {
    position: relative;
    min-height: 100vh;
    isolation: isolate;
}

/* Paper-grain overlay */
.cc-grain {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    mix-blend-mode: overlay;
    opacity: 0.6;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 0.55 0'/></filter><rect width='240' height='240' filter='url(%23n)' opacity='0.18'/></svg>");
}

/* Left kraft binding strip */
.cc-binding {
    position: fixed;
    top: 0;
    left: 0;
    width: 8px;
    height: 100%;
    z-index: 10;
    pointer-events: none;
    background-color: var(--color-brand-cream);
    background-image:
        radial-gradient(circle, rgba(0,0,0,0.32) 0 1px, transparent 1.4px),
        linear-gradient(to right, rgba(0,0,0,0.18) 0, rgba(0,0,0,0) 100%);
    background-size: 8px 8px, 100% 100%;
    background-position: center, left center;
    background-repeat: repeat-y, no-repeat;
    box-shadow: inset -1px 0 0 rgba(0,0,0,0.18), 1px 0 8px rgba(0,0,0,0.25);
    opacity: 0.92;
}
@media (min-width: 768px) {
    .cc-binding { width: 12px; background-size: 12px 12px, 100% 100%; }
}

/* Floating logo (top-left) — stacked two-line Gambarino wordmark */
.cc-logo {
    position: fixed;
    top: 1rem;
    left: 1.25rem;
    z-index: 50;
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    color: var(--color-brand-cream);
    text-decoration: none;
    filter: drop-shadow(0 1px 12px rgba(4,23,57,0.6));
    transition: opacity 0.2s ease;
}
@media (min-width: 768px) { .cc-logo { top: 1.25rem; left: 1.5rem; } }
.cc-logo:hover { opacity: 0.8; text-decoration: none; }

/* Both lines: Gambarino, same size, stacked — matches curiouscircle.com wordmark */
.cc-logo-mark,
.cc-logo-sub {
    font-family: var(--font-display);
    font-size: clamp(0.9rem, 2.5vw, 1.25rem);
    font-weight: 400;
    line-height: 1.1;
    letter-spacing: 0.04em;
    text-transform: none;
    opacity: 1;
    margin: 0;
    display: block;
}

/* Floating JOIN (top-right) */
.cc-nav {
    position: fixed;
    top: 1.1rem;
    right: 1.25rem;
    z-index: 50;
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--color-brand-cream);
    text-shadow: 0 1px 12px rgba(4,23,57,0.6);
}
@media (min-width: 480px) { .cc-nav { font-size: 0.8125rem; right: 1.75rem; } }
.cc-nav a {
    color: var(--color-brand-cream);
    text-underline-offset: 4px;
    text-decoration: none;
}
.cc-nav a:hover { text-decoration: underline; }

/* -----------------------------------------------------------------------------
   Article container
   -------------------------------------------------------------------------- */

.cc-article {
    position: relative;
    z-index: 20;
    /* Top padding must clear the fixed logo + nav bar.
       Logo is ~1.75rem tall + 1rem top offset = ~2.75rem.
       Add generous breathing room so content never overlaps on any screen. */
    padding: 5rem var(--page-x) 4rem calc(var(--page-x) + 12px);
}
@media (min-width: 480px) { .cc-article { padding-top: 5.5rem; } }
@media (min-width: 768px) { .cc-article { padding-top: 6rem; } }

/* Back link */
.cc-back { margin-bottom: 2rem; }
@media (min-width: 768px) { .cc-back { margin-bottom: 2.5rem; } }

.cc-back a,
.cc-footer-back a {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--color-brand-cream);
    text-decoration: none;
    transition: color 0.2s ease;
}
@media (min-width: 480px) {
    .cc-back a, .cc-footer-back a { font-size: 0.8125rem; }
}
.cc-back a:hover,
.cc-footer-back a:hover { color: var(--color-brand-rust); text-decoration: none; }

/* -----------------------------------------------------------------------------
   Postcard header card
   -------------------------------------------------------------------------- */

.cc-postcard {
    width: 100%;
    max-width: var(--card-col);
    margin: 0 auto 2.5rem;
    background-color: rgba(244, 237, 225, 0.04);
    border: 1px solid var(--border-cream-soft);
    border-radius: 4px;
    overflow: hidden;
    box-shadow:
        0 1px 0 rgba(244, 237, 225, 0.05) inset,
        0 24px 60px -28px rgba(0, 0, 0, 0.55),
        0 8px 18px -10px rgba(0, 0, 0, 0.4);
}
@media (min-width: 768px) {
    .cc-postcard { border-radius: 6px; margin-bottom: 3rem; }
}

.cc-postcard-image { background-color: var(--color-brand-dark); }
.cc-postcard-image img {
    width: 100%;
    height: auto;
    filter: saturate(0.95) contrast(1.02);
}
.cc-feature-caption {
    padding: 0.5rem 1rem;
    font-family: var(--font-mono);
    font-size: 0.625rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    opacity: 0.7;
    border-top: 1px solid var(--border-cream-soft);
}

.cc-postcard-meta {
    padding: 1.5rem 1.25rem 1.5rem;
}
@media (min-width: 480px) { .cc-postcard-meta { padding: 2rem 1.75rem; } }
@media (min-width: 768px) { .cc-postcard-meta { padding: 2.5rem 2.5rem 2.25rem; } }

.cc-meta-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0.75rem;
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    opacity: 0.8;
    margin-bottom: 1rem;
}
@media (min-width: 480px) { .cc-meta-row { font-size: 0.75rem; margin-bottom: 1.25rem; } }

.cc-meta-dot {
    display: inline-block;
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background-color: currentColor;
    flex-shrink: 0;
}
@media (min-width: 480px) { .cc-meta-dot { width: 4px; height: 4px; } }

/* Fluid title: 1.75rem phone → 3.25rem desktop */
.cc-title {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: clamp(1.75rem, 4vw + 0.5rem, 3.25rem);
    line-height: 1.05;
    letter-spacing: -0.01em;
    color: var(--color-brand-cream);
    margin: 0 0 0.875rem;
}

.cc-excerpt {
    font-family: var(--font-display);
    font-style: italic;
    font-size: clamp(1rem, 1.5vw + 0.5rem, 1.25rem);
    line-height: 1.5;
    opacity: 0.9;
    margin: 0 0 1.25rem;
}

.cc-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}
.cc-tag {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    font-family: var(--font-mono);
    font-size: 0.625rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    background-color: rgba(244, 237, 225, 0.08);
    border: 1px solid var(--border-cream-mid);
    border-radius: 9999px;
}
@media (min-width: 480px) {
    .cc-tag { font-size: 0.6875rem; padding: 0.25rem 0.75rem; }
}

/* -----------------------------------------------------------------------------
   Body prose — centered reading column
   -------------------------------------------------------------------------- */

.cc-body {
    width: 100%;
    max-width: var(--read-col);
    margin: 0 auto;
    font-family: var(--font-body);
    /* Fluid body type: 1rem phone → 1.125rem desktop */
    font-size: clamp(1rem, 0.9rem + 0.4vw, 1.125rem);
    line-height: 1.8;
}

.cc-body > * + * { margin-top: 1.25em; }

.cc-body p {
    color: var(--color-brand-cream);
    margin: 0 0 1.25em;
}
.cc-body p:last-child { margin-bottom: 0; }

.cc-body h2,
.cc-body h3,
.cc-body h4 {
    font-family: var(--font-display);
    font-weight: 400;
    color: var(--color-brand-cream);
    letter-spacing: -0.005em;
    line-height: 1.2;
    margin: 2em 0 0.6em;
}
/* Fluid headings */
.cc-body h2 { font-size: clamp(1.375rem, 2vw + 0.5rem, 1.875rem); }
.cc-body h3 { font-size: clamp(1.125rem, 1.5vw + 0.25rem, 1.375rem); }
.cc-body h4 { font-size: clamp(1rem, 1vw + 0.25rem, 1.125rem); }

.cc-body a {
    color: var(--color-brand-rust);
    text-decoration: none;
    border-bottom: 1px solid rgba(200, 107, 74, 0.4);
    transition: border-color 0.15s ease;
}
.cc-body a:hover { border-bottom-color: var(--color-brand-rust); text-decoration: none; }

.cc-body strong { color: var(--color-brand-cream); font-weight: 700; }
.cc-body em { font-style: italic; }

.cc-body ul, .cc-body ol { padding-left: 1.4em; margin: 0 0 1.25em; }
@media (min-width: 480px) { .cc-body ul, .cc-body ol { padding-left: 1.6em; } }
.cc-body li { margin: 0.35em 0; }
.cc-body li::marker { color: rgba(244, 237, 225, 0.5); }

.cc-body blockquote {
    margin: 1.75em 0;
    padding: 0.5em 0 0.5em 1.1em;
    border-left: 3px solid var(--color-brand-rust);
    font-style: italic;
    color: var(--color-brand-cream);
    opacity: 0.92;
}
@media (min-width: 480px) {
    .cc-body blockquote { padding-left: 1.25em; margin: 2em 0; }
}
.cc-body blockquote p { margin: 0.5em 0; }

.cc-body hr {
    border: 0;
    border-top: 1px solid var(--border-cream-mid);
    margin: 2.5em auto;
    max-width: 6rem;
}
@media (min-width: 480px) { .cc-body hr { margin: 3em auto; max-width: 8rem; } }

.cc-body code {
    font-family: var(--font-mono);
    font-size: 0.88em;
    padding: 0.1em 0.35em;
    background-color: rgba(244, 237, 225, 0.08);
    border: 1px solid var(--border-cream-soft);
    border-radius: 3px;
    word-break: break-word;
}

.cc-body pre {
    font-family: var(--font-mono);
    font-size: clamp(0.75rem, 1.5vw, 0.875rem);
    line-height: 1.55;
    padding: 1rem 1.1rem;
    background-color: rgba(244, 237, 225, 0.06);
    border: 1px solid var(--border-cream-mid);
    border-radius: 4px;
    overflow-x: auto;
    margin: 1.5em 0;
    /* Prevent pre from overflowing the card column on mobile */
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
}
@media (min-width: 480px) { .cc-body pre { padding: 1.25rem 1.5rem; border-radius: 6px; } }
.cc-body pre code {
    padding: 0;
    background: none;
    border: 0;
    border-radius: 0;
    word-break: normal;
    font-size: inherit;
}

/* Images & figures */
.cc-body img,
.cc-body figure img {
    margin: 0 auto;
    border-radius: 4px;
}
.cc-body figure { margin: 1.75em 0; }
@media (min-width: 480px) { .cc-body figure { margin: 2em 0; } }
.cc-body figcaption {
    font-family: var(--font-mono);
    font-size: 0.625rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    opacity: 0.7;
    text-align: center;
    margin-top: 0.6em;
}
@media (min-width: 480px) { .cc-body figcaption { font-size: 0.6875rem; margin-top: 0.75em; } }

/* -----------------------------------------------------------------------------
   Koenig card overrides
   -------------------------------------------------------------------------- */

/* Wide / full-bleed images break out of the reading column */
.cc-body .kg-width-wide,
.cc-body figure.kg-width-wide {
    max-width: var(--card-col);
    margin-left: 50%;
    transform: translateX(-50%);
}
.cc-body .kg-width-full,
.cc-body figure.kg-width-full {
    width: 100vw;
    max-width: 100vw;
    margin-left: 50%;
    transform: translateX(-50%);
}
.cc-body .kg-width-full img { border-radius: 0; }

/* Bookmark card */
.cc-body .kg-bookmark-card,
.cc-body .kg-bookmark-container {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-cream-mid);
    border-radius: 6px;
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    background-color: rgba(244, 237, 225, 0.04);
    transition: background-color 0.2s ease;
}
@media (min-width: 480px) {
    .cc-body .kg-bookmark-card,
    .cc-body .kg-bookmark-container { flex-direction: row; }
}
.cc-body .kg-bookmark-card:hover,
.cc-body .kg-bookmark-container:hover { background-color: rgba(244, 237, 225, 0.07); }
.cc-body .kg-bookmark-content { padding: 1rem; flex: 1; min-width: 0; }
@media (min-width: 480px) { .cc-body .kg-bookmark-content { padding: 1.25rem; } }
.cc-body .kg-bookmark-title {
    font-family: var(--font-display);
    color: var(--color-brand-cream);
    font-weight: 400;
    font-size: 1rem;
    line-height: 1.3;
    margin-bottom: 0.4rem;
}
.cc-body .kg-bookmark-description {
    font-size: 0.875rem;
    opacity: 0.8;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 0.75rem;
}
.cc-body .kg-bookmark-metadata {
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    opacity: 0.65;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 0.75rem;
    align-items: center;
}
.cc-body .kg-bookmark-icon { width: 14px; height: 14px; flex-shrink: 0; }
.cc-body .kg-bookmark-thumbnail {
    flex: 0 0 100%;
    max-height: 160px;
    overflow: hidden;
}
@media (min-width: 480px) { .cc-body .kg-bookmark-thumbnail { flex: 0 0 33%; max-height: none; } }
.cc-body .kg-bookmark-thumbnail img { width: 100%; height: 100%; object-fit: cover; border-radius: 0; }

/* Callout card */
.cc-body .kg-callout-card {
    display: flex;
    gap: 0.75rem;
    padding: 1rem 1.1rem;
    border: 1px solid var(--border-cream-mid);
    border-radius: 6px;
    background-color: rgba(244, 237, 225, 0.05);
    margin: 1.5em 0;
}
@media (min-width: 480px) { .cc-body .kg-callout-card { padding: 1.25rem 1.5rem; } }
.cc-body .kg-callout-emoji { font-size: 1.25rem; line-height: 1.5; flex-shrink: 0; }
.cc-body .kg-callout-text { flex: 1; min-width: 0; }

/* Gallery */
.cc-body .kg-gallery-container { display: flex; flex-direction: column; gap: 0.5rem; margin: 1.5em 0; }
@media (min-width: 480px) { .cc-body .kg-gallery-container { gap: 0.75rem; } }
.cc-body .kg-gallery-row { display: flex; gap: 0.5rem; }
@media (min-width: 480px) { .cc-body .kg-gallery-row { gap: 0.75rem; } }
.cc-body .kg-gallery-image { flex: 1; min-width: 0; }
.cc-body .kg-gallery-image img { width: 100%; height: 100%; object-fit: cover; }

/* Button card */
.cc-body .kg-button-card { text-align: center; margin: 1.75em 0; }
.cc-body .kg-btn {
    display: inline-block;
    padding: 0.65rem 1.5rem;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    background-color: var(--color-brand-rust);
    color: var(--color-brand-cream);
    border: 1px solid var(--color-brand-rust);
    border-radius: 4px;
    text-decoration: none;
    transition: opacity 0.2s ease;
}
@media (min-width: 480px) { .cc-body .kg-btn { font-size: 0.8125rem; padding: 0.75rem 1.75rem; } }
.cc-body .kg-btn:hover { opacity: 0.9; text-decoration: none; }

/* Embed (YouTube etc.) */
.cc-body .kg-embed-card { margin: 1.5em 0; text-align: center; }
.cc-body .kg-embed-card iframe { max-width: 100%; width: 100%; border-radius: 4px; aspect-ratio: 16/9; height: auto; }

/* -----------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */

.cc-footer {
    width: 100%;
    max-width: var(--read-col);
    margin: 3.5rem auto 0;
    padding-top: 2rem;
    border-top: 1px solid var(--border-cream-mid);
}
@media (min-width: 480px) { .cc-footer { margin-top: 4rem; } }

.cc-subscribe {
    background-color: rgba(244, 237, 225, 0.04);
    border: 1px solid var(--border-cream-mid);
    border-radius: 6px;
    padding: 1.5rem 1.25rem 1.75rem;
    margin-bottom: 2rem;
    text-align: center;
}
@media (min-width: 480px) { .cc-subscribe { padding: 1.75rem 1.75rem 2rem; margin-bottom: 2.5rem; } }
.cc-subscribe-kicker {
    font-family: var(--font-mono);
    font-size: 0.625rem;
    letter-spacing: 0.28em;
    text-transform: uppercase;
    opacity: 0.7;
    margin: 0 0 0.5rem;
}
@media (min-width: 480px) { .cc-subscribe-kicker { font-size: 0.6875rem; letter-spacing: 0.32em; } }
.cc-subscribe-lede {
    font-family: var(--font-display);
    font-size: clamp(0.9375rem, 1.5vw + 0.25rem, 1.0625rem);
    line-height: 1.45;
    margin: 0 0 1.25rem;
    opacity: 0.92;
}
.cc-subscribe-cta {
    display: inline-block;
    padding: 0.6rem 1.25rem;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--color-brand-cream);
    background-color: rgba(200, 107, 74, 0.15);
    border: 1px solid var(--color-brand-rust);
    border-radius: 4px;
    text-decoration: none;
    transition: background-color 0.2s ease;
}
@media (min-width: 480px) { .cc-subscribe-cta { padding: 0.6rem 1.5rem; font-size: 0.8125rem; } }
.cc-subscribe-cta:hover { background-color: rgba(200, 107, 74, 0.3); text-decoration: none; }

.cc-footer-back { text-align: left; }

/* -----------------------------------------------------------------------------
   Ghost Portal trigger — hidden intentionally.
   The floating "Sign up" button is redundant alongside the "Join" nav link
   (which sends visitors to the curiouscircle.com/?panel=join flow).
   Hiding the trigger does NOT break Portal functionality: unsubscribe links,
   magic links, and member account management all use direct URL deep-links
   that open the Portal modal without the trigger button.
   -------------------------------------------------------------------------- */

/* Hide just the trigger iframe, not the popup iframe (needed for unsubscribe/magic links) */
#ghost-portal-root iframe[title="portal-trigger"],
#ghost-portal-root iframe[title="memberships-portal-trigger"] {
    display: none !important;
}
.gh-portal-triggerbtn-wrapper { display: none !important; }

/* -----------------------------------------------------------------------------
   Selection
   -------------------------------------------------------------------------- */

::selection {
    background-color: rgba(200, 107, 74, 0.45);
    color: var(--color-brand-cream);
}
