/* ==========================================================================
   Base — Tasarım belirteçleri, reset, tipografi, doku
   Sanat yönü: "yazma eser kartografisi" — kâğıt zemin, mürekkep çizgi,
   başlıklarda sürh (kırmızı mürekkep) vurgusu, ince cetvel çizgileri.
   ========================================================================== */

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

:root {
    /* Kâğıt */
    --paper: #f4eee3;
    --paper-raised: #faf6ee;
    --paper-sunk: #ebe3d3;

    /* Mürekkep */
    --ink: #1d1b16;
    --ink-soft: #3d3830;
    --ink-muted: #73695a;

    /* Cetvel (çizgi) */
    --rule: #d9cdb7;
    --rule-strong: #b6a586;

    /* Vurgu: sürh */
    --accent: #ad3f27;
    --accent-deep: #8b311e;
    --accent-tint: #efd9cd;

    /* Tezhip altını — yalnızca ince süsleme için */
    --gold: #a07f45;

    /* Gece (footer) */
    --night: #17150f;
    --night-raised: #221f17;
    --on-night: #efe7d8;
    --on-night-muted: #a59c8a;

    /* Tipografi */
    --font-display: 'Fraunces', 'Iowan Old Style', Georgia, serif;
    --font-body: 'Hanken Grotesk', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, 'Cascadia Mono', Consolas, monospace;
    --font-arabic: 'Amiri', 'Traditional Arabic', serif;

    /* Ölçüler */
    --navbar-height: 76px;
    --max-width: 1240px;
    --gutter: clamp(1rem, 4vw, 2.5rem);
    --radius-sm: 3px;
    --radius-md: 6px;

    /* Gölge: kâğıt tonuna boyanmış */
    --shadow-paper: 0 1px 0 rgba(255, 255, 255, 0.6) inset, 0 18px 40px -24px rgba(74, 56, 28, 0.35);

    /* Hareket */
    --ease-out: cubic-bezier(0.22, 1, 0.36, 1);

    /* Katman sırası */
    --z-grain: 90;
    --z-nav: 100;
    --z-toast: 200;
    --z-skip: 300;
}

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

body {
    font-family: var(--font-body);
    font-size: 1.0625rem;
    line-height: 1.7;
    color: var(--ink-soft);
    background-color: var(--paper);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* Kâğıt dokusu: sabit, tıklanamaz gren katmanı */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: var(--z-grain);
    pointer-events: none;
    opacity: 0.55;
    mix-blend-mode: multiply;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .42 0 0 0 0 .34 0 0 0 0 .2 0 0 0 .09 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

::selection {
    background: var(--accent);
    color: var(--paper-raised);
}

img,
svg {
    max-width: 100%;
    height: auto;
    display: block;
}

a {
    color: var(--ink);
    text-decoration: none;
    transition: color 0.25s ease;
}

a:hover {
    color: var(--accent);
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    font-weight: 400;
    line-height: 1.08;
    color: var(--ink);
    font-optical-sizing: auto;
    text-wrap: balance;
}

h1 { font-size: clamp(2.6rem, 6vw, 4.6rem); letter-spacing: -0.025em; }
h2 { font-size: clamp(2.1rem, 4.2vw, 3.5rem); letter-spacing: -0.02em; }
h3 { font-size: 1.5rem; letter-spacing: -0.01em; font-weight: 500; }
h4 { font-size: 1.15rem; font-weight: 500; }

h1 em,
h2 em,
h3 em {
    font-style: italic;
    color: var(--accent);
}

p {
    max-width: 64ch;
    text-wrap: pretty;
}

ul, ol {
    list-style: none;
}

button {
    font: inherit;
    color: inherit;
    cursor: pointer;
    border: none;
    background: none;
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
    border-radius: 2px;
}

[lang="ar"] {
    font-family: var(--font-arabic);
}

/* Yardımcılar */
.mono {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    letter-spacing: 0.02em;
    font-variant-numeric: tabular-nums;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: fixed;
    top: -100px;
    inset-inline-start: 1rem;
    background: var(--ink);
    color: var(--paper);
    padding: 0.6rem 1rem;
    z-index: var(--z-skip);
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}

.skip-link:focus {
    top: 0;
    color: var(--paper);
}

/* Kaydırma çubuğu */
::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-track { background: var(--paper-sunk); }
::-webkit-scrollbar-thumb { background: var(--rule-strong); border: 2px solid var(--paper-sunk); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: var(--ink-muted); }

/* Görünüme girerken açılma (JS varsa) */
.js [data-reveal] {
    opacity: 0;
    transform: translateY(26px);
    transition: opacity 0.9s var(--ease-out), transform 0.9s var(--ease-out);
    transition-delay: calc(var(--d, 0) * 90ms);
}

.js [data-reveal].is-visible {
    opacity: 1;
    transform: none;
}

/* Çeviri uygulanana dek gizle (lang-boot.js ekler, i18n.js kaldırır) */
.i18n-pending body {
    visibility: hidden;
}

/* ---- Arapça: yazı tipleri ve yazım kuralları ---- */
html[lang="ar"] {
    --font-display: 'Amiri', 'Traditional Arabic', serif;
    --font-body: 'IBM Plex Sans Arabic', 'Hanken Grotesk', 'Segoe UI', sans-serif;
    /* JetBrains Mono'da Arapça harf yok: Arapça karakterler Plex Arabic ile çizilsin */
    --font-mono: 'JetBrains Mono', 'IBM Plex Sans Arabic', ui-monospace, monospace;
}

/* Arapça harfler birbirine bağlanır: harf aralığı bitişik yazıyı bozar */
html[lang="ar"] body,
html[lang="ar"] body * {
    letter-spacing: 0 !important;
}

html[lang="ar"] body {
    font-size: 1.1rem;
    line-height: 1.9;
}

html[lang="ar"] h1,
html[lang="ar"] h2,
html[lang="ar"] h3,
html[lang="ar"] h4 {
    line-height: 1.4;
    font-weight: 700;
}

/* Arapçada italik yoktur (eğik Arapça yapay durur); vurgu yalnızca renkle */
html[lang="ar"] body * {
    font-style: normal;
}

/* Latin marka adı her dilde Fraunces kalır */
html[lang="ar"] .brand-name,
html[lang="ar"] .footer-wordmark {
    font-family: 'Fraunces', Georgia, serif;
}

html[lang="ar"] .brand-name span,
html[lang="ar"] .footer-wordmark em {
    font-style: italic;
}

/* Yön okları sağdan sola düzende ters döner */
[dir="rtl"] .arrow,
[dir="rtl"] .arrow-back {
    display: inline-block;
    transform: scaleX(-1);
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    .js [data-reveal] {
        opacity: 1;
        transform: none;
    }
}
