/* ============================================================
   علی ابراهیمی — یادداشت‌ها (v2 · نسخه‌ی حس‌دار)
   Single source of truth for styling across every page.
   ============================================================ */

:root{
  /* Warm editorial paper */
  --bg:40 33% 98%;
  --surface:38 30% 96%;
  --surface-2:36 26% 93%;
  --fg:28 12% 14%;
  --muted:30 7% 44%;
  --border:32 18% 87%;
  --border-strong:30 14% 78%;
  --accent:185 78% 31%;            /* teal — the identity color */
  --accent-soft:185 60% 45%;
  --ring:185 78% 31%;
  --shadow:30 30% 20% / .18;
  --radius:.6rem;
  --grain:.05;                      /* grain opacity */

  /* Type scale — single source of truth for every size across all pages */
  --fs-hero:clamp(2rem,4.8vw,2.7rem);   /* homepage statement */
  --fs-title:clamp(1.45rem,3vw,1.85rem);/* post title: featured card AND article page (same) */
  --fs-lede:1.04rem;                    /* hero lede */
  --fs-body:1.05rem;                    /* article body */
  --fs-row:1.1rem;                      /* list-row title */
  --fs-meta:.8rem;                      /* meta lines */
}
.dark{
  /* Warm charcoal — never pure black */
  --bg:28 11% 9%;
  --surface:28 10% 12%;
  --surface-2:28 9% 15%;
  --fg:40 20% 92%;
  --muted:36 9% 60%;
  --border:32 8% 20%;
  --border-strong:32 8% 28%;
  --accent:183 66% 54%;
  --accent-soft:183 50% 62%;
  --ring:183 66% 54%;
  --shadow:0 0% 0% / .5;
  --grain:.06;
}

*{box-sizing:border-box;margin:0;padding:0}
html{scroll-behavior:smooth}
::selection{background:hsl(var(--accent));color:hsl(var(--bg))}

body{
  font-family:"Vazirmatn",system-ui,sans-serif;
  background:hsl(var(--bg));
  color:hsl(var(--fg));
  line-height:1.9;
  -webkit-font-smoothing:antialiased;
  transition:background-color .35s ease,color .35s ease;
  position:relative;
}
/* Subtle film grain over everything */
body::before{
  content:"";position:fixed;inset:0;z-index:1;pointer-events:none;
  opacity:var(--grain);mix-blend-mode:overlay;
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
body > *{position:relative;z-index:2}

.mono{font-family:ui-monospace,"SF Mono",SFMono-Regular,Menlo,"JetBrains Mono",monospace;letter-spacing:0}
a{color:inherit;text-decoration:none}

/* Custom scrollbar */
*{scrollbar-width:thin;scrollbar-color:hsl(var(--border-strong)) transparent}
*::-webkit-scrollbar{width:10px;height:10px}
*::-webkit-scrollbar-thumb{background:hsl(var(--border-strong));border-radius:999px;border:3px solid hsl(var(--bg))}
*::-webkit-scrollbar-thumb:hover{background:hsl(var(--muted))}

.wrap{max-width:900px;margin:0 auto;padding:0 1.4rem}

/* Reading-progress bar (post pages) */
.progress{position:fixed;top:0;right:0;height:3px;width:0;z-index:60;background:hsl(var(--accent));transition:width .08s linear}

/* Entrance animation — transform only, opacity stays 1 throughout, so content
   is ALWAYS visible even if the animation never advances. Real users get a
   subtle slide-up; there is no way for this to blank the page. */
@keyframes rise{from{transform:translateY(14px)}to{transform:none}}
.js .reveal{animation:rise .55s cubic-bezier(.2,.7,.2,1)}

/* ---------- Header ---------- */
header.site{
  position:sticky;top:0;z-index:50;
  background:hsl(var(--bg) / .72);
  backdrop-filter:saturate(160%) blur(12px);
  -webkit-backdrop-filter:saturate(160%) blur(12px);
  border-bottom:1px solid hsl(var(--border) / .7);
}
.site-inner{display:flex;align-items:center;justify-content:space-between;gap:1rem;flex-wrap:wrap;padding:.9rem 0}
.brand{display:flex;align-items:center;gap:.5rem;cursor:pointer}
.brand .mark{
  font-family:ui-monospace,monospace;font-weight:700;color:hsl(var(--accent));
  background:hsl(var(--accent) / .1);border:1px solid hsl(var(--accent) / .25);
  border-radius:.4rem;padding:.05rem .32rem;font-size:.9rem;line-height:1.4;
}
.brand .name{font-size:1.02rem;font-weight:800;letter-spacing:-.01em}
.nav{display:flex;align-items:center;gap:.15rem}
.nav a{
  font-size:.9rem;color:hsl(var(--muted));cursor:pointer;
  padding:.35rem .6rem;border-radius:.4rem;transition:color .18s,background-color .18s;
}
.nav a:hover{color:hsl(var(--fg));background:hsl(var(--surface))}
.nav a.active{color:hsl(var(--fg));font-weight:700}
.icon-btn{
  width:34px;height:34px;display:grid;place-items:center;margin-inline-start:.15rem;
  border:1px solid hsl(var(--border));border-radius:.45rem;
  background:transparent;color:hsl(var(--fg));cursor:pointer;
  transition:background-color .18s,border-color .18s,transform .2s;
}
.icon-btn:hover{background:hsl(var(--surface));transform:rotate(-12deg)}
.icon-btn svg{width:17px;height:17px}

/* ---------- Hero ---------- */
.hero{padding:2rem 0 1.2rem}
.hero h1{font-size:var(--fs-hero);line-height:1.28;font-weight:800;letter-spacing:-.03em;margin-bottom:.8rem}
.hero h1 .hl{
  white-space:nowrap;border-radius:.12em;
  background-image:linear-gradient(hsl(var(--accent) / .22), hsl(var(--accent) / .22));
  background-size:100% .34em;background-repeat:no-repeat;background-position:0 .82em;
}
.hero .lede{color:hsl(var(--muted));font-size:var(--fs-lede);line-height:1.85;max-width:52ch}
.hero .lede b{color:hsl(var(--fg));font-weight:700}

/* ---------- Featured post ---------- */
.sec-label{
  display:flex;align-items:center;gap:.7rem;margin:2rem 0 1rem;
  font-size:.8rem;color:hsl(var(--muted));font-weight:600;letter-spacing:.02em;
}
.sec-label::after{content:"";flex:1;height:1px;background:hsl(var(--border))}

.featured{
  display:block;position:relative;overflow:hidden;
  padding:1.5rem;margin-bottom:1.8rem;
  border:1px solid hsl(var(--border));border-radius:calc(var(--radius) + .3rem);
  background:hsl(var(--surface));
  transition:transform .28s cubic-bezier(.2,.7,.2,1),border-color .28s,box-shadow .28s;
}
.featured:hover{border-color:hsl(var(--accent) / .5);box-shadow:0 24px 50px -28px hsl(var(--shadow))}
.featured .ribbon{font-size:.74rem;font-weight:700;color:hsl(var(--accent));letter-spacing:.04em;margin-bottom:.7rem;display:inline-block}
.featured h2{font-size:var(--fs-title);line-height:1.4;font-weight:800;letter-spacing:-.02em;margin-bottom:.6rem}
.featured p{color:hsl(var(--muted));font-size:1rem;line-height:1.85;margin-bottom:.9rem;max-width:56ch}
.post-meta{font-size:var(--fs-meta);color:hsl(var(--muted));display:flex;align-items:center;gap:.55rem;flex-wrap:wrap}
.post-meta .cat{color:hsl(var(--accent));font-weight:600}
.post-meta .dot{width:3px;height:3px;border-radius:50%;background:hsl(var(--border-strong))}

/* ---------- Post list ---------- */
.postlist{display:flex;flex-direction:column;margin-bottom:1rem}
a.post{
  display:grid;grid-template-columns:auto 1fr auto;gap:1rem;align-items:center;
  padding:1.15rem .5rem;border-bottom:1px solid hsl(var(--border));
  border-radius:.5rem;transition:background-color .2s;
}
a.post:hover{background:hsl(var(--surface))}
a.post .idx{font-size:.82rem;color:hsl(var(--muted));font-variant-numeric:tabular-nums;min-width:1.7rem;text-align:center}
a.post .p-body{min-width:0}
a.post .p-title{
  font-size:var(--fs-row);font-weight:700;line-height:1.5;letter-spacing:-.01em;display:block;margin-bottom:.2rem;
}
a.post:hover .p-title{color:hsl(var(--accent))}
a.post .arrow{color:hsl(var(--muted));font-size:1.1rem;transition:transform .22s,color .22s;flex:none}
a.post:hover .arrow{transform:translateX(-5px);color:hsl(var(--accent))}

/* ---------- Standalone pages (Now / Uses / About) ---------- */
.page-head{padding:2rem 0 1rem}
.page-head .kicker{color:hsl(var(--accent));font-size:.8rem;font-weight:700;margin-bottom:.5rem;letter-spacing:.02em}
.page-head h1{font-size:var(--fs-title);font-weight:800;letter-spacing:-.02em;line-height:1.35}
.page-body{padding-bottom:1.4rem}
.page-body h3{font-size:1.35rem;font-weight:800;letter-spacing:-.01em;margin:1.6rem 0 .7rem}
.page-body h3:first-child{margin-top:0}
.page-body p{color:hsl(var(--muted));margin-bottom:.9rem}
.page-body p b{color:hsl(var(--fg));font-weight:700}
.page-body a.inline{color:hsl(var(--accent));font-weight:600}
.page-body a.inline:hover{text-decoration:underline}
.page-body .note{font-size:.82rem;color:hsl(var(--muted));margin-top:.4rem}

/* ---------- Now page timeline ---------- */
.now-updated{color:hsl(var(--accent));font-size:.78rem;font-weight:700;margin-bottom:.6rem}
.now-sep{display:flex;align-items:center;gap:.8rem;margin:2.4rem 0 1.4rem;font-size:.82rem;color:hsl(var(--muted))}
.now-sep::after{content:"";flex:1;height:1px;background:hsl(var(--border))}
.now-history{border-right:2px solid hsl(var(--border));padding-right:1.4rem;margin-right:.35rem;display:flex;flex-direction:column;gap:1.7rem}
.now-entry{position:relative}
.now-entry::before{
  content:"";position:absolute;top:.55rem;right:calc(-1.4rem - 5px);
  width:9px;height:9px;border-radius:50%;background:hsl(var(--bg));border:2px solid hsl(var(--accent));
}
.now-entry-date{font-size:.92rem;font-weight:700;color:hsl(var(--fg));margin-bottom:.15rem}
.now-entry-body{color:hsl(var(--muted));font-size:.95rem}
.now-entry-body p{margin-bottom:.5rem}
.now-entry-body p:last-child{margin-bottom:0}

/* ---------- Uses ---------- */
.uses{list-style:none;display:flex;flex-direction:column;gap:.1rem;margin-top:.4rem}
.uses li{display:flex;gap:.9rem;align-items:baseline;padding:.6rem 0;border-bottom:1px dashed hsl(var(--border))}
.uses li:last-child{border-bottom:none}
.uses .k{color:hsl(var(--fg));font-weight:700;font-size:.95rem;min-width:8.5rem}
.uses .v{color:hsl(var(--muted));font-size:.92rem}

/* ---------- Newsletter ---------- */
.newsletter{
  display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:1.4rem 2.4rem;
  padding:1.9rem;border:1px solid hsl(var(--border));border-radius:calc(var(--radius) + .2rem);
  background:hsl(var(--surface));margin-top:1.4rem;
}
.nl-text{flex:1 1 300px}
.newsletter h3{font-size:1.3rem;font-weight:800;margin-bottom:.4rem}
.newsletter p{color:hsl(var(--muted));margin:0;max-width:46ch}
.nl-cta{flex:1 1 360px;max-width:460px}
.nl-form{display:flex;gap:.5rem}
.nl-form input{
  flex:1;font-family:inherit;font-size:.95rem;padding:.6rem .85rem;
  border:1px solid hsl(var(--border-strong));border-radius:.5rem;
  background:hsl(var(--bg));color:hsl(var(--fg));
}
.nl-form input:focus{outline:2px solid hsl(var(--ring)/.35);outline-offset:1px;border-color:hsl(var(--ring))}
.nl-form button{
  font-family:inherit;font-size:.95rem;font-weight:700;cursor:pointer;white-space:nowrap;
  padding:.6rem 1.2rem;border:none;border-radius:.5rem;
  background:hsl(var(--accent));color:hsl(var(--bg));transition:opacity .18s,transform .18s;
}
.nl-form button:hover{opacity:.9;transform:translateY(-1px)}
.nl-note{margin-top:.8rem;font-size:.88rem;color:hsl(var(--accent));min-height:1.1rem}
.nl-note:empty{display:none;margin:0;min-height:0}  /* don't reserve height before submit — keeps the form vertically centered */

/* ---------- Article (post.html) ---------- */
.article{padding:1.4rem 0 3rem}
.back-btn{
  display:inline-flex;align-items:center;gap:.45rem;font-family:inherit;font-size:.88rem;
  cursor:pointer;background:none;border:none;color:hsl(var(--muted));margin-bottom:2rem;transition:color .18s;
}
.back-btn:hover{color:hsl(var(--fg))}
.back-btn svg{width:15px;height:15px}
.article-head .meta{font-size:var(--fs-meta);color:hsl(var(--muted));display:flex;align-items:center;gap:.55rem;margin-bottom:.7rem;flex-wrap:wrap}
.article-head .meta .cat{color:hsl(var(--accent));font-weight:600}
.article-head .meta .dot{width:3px;height:3px;border-radius:50%;background:hsl(var(--border-strong))}
.article-head h1{font-size:var(--fs-title);line-height:1.4;font-weight:800;letter-spacing:-.02em;margin-bottom:1.4rem}
.article-body{font-size:var(--fs-body);line-height:1.98}
.article-body p{margin-bottom:1.3rem}
.article-body h2{font-size:1.42rem;font-weight:800;margin:2.2rem 0 .9rem;letter-spacing:-.01em}
.article-body ul,.article-body ol{margin:0 1.2rem 1.4rem 0;padding-right:1rem}
.article-body li{margin-bottom:.55rem}
.article-body strong{font-weight:700;color:hsl(var(--fg))}
.article-body blockquote{
  border-right:3px solid hsl(var(--accent));margin:1.8rem 0;padding:.4rem 1.2rem;
  font-size:1.18rem;font-weight:600;line-height:1.75;color:hsl(var(--fg));
  background:hsl(var(--accent) / .05);border-radius:0 .4rem .4rem 0;
}
.article-body pre{
  background:hsl(var(--surface-2));border:1px solid hsl(var(--border));border-radius:var(--radius);
  padding:1.1rem;overflow-x:auto;margin:1.5rem 0;direction:ltr;text-align:left;
}
.article-body code{font-family:ui-monospace,"SF Mono",Menlo,Consolas,monospace;font-size:.86rem;line-height:1.7}
.article-body p code,.article-body li code{background:hsl(var(--surface-2));padding:.08rem .32rem;border-radius:.28rem}

/* prev / next */
.post-nav{display:grid;grid-template-columns:1fr 1fr;gap:1rem;margin-top:3rem;padding-top:1.6rem;border-top:1px solid hsl(var(--border))}
.post-nav a{
  display:block;padding:1rem 1.1rem;border:1px solid hsl(var(--border));border-radius:var(--radius);
  background:hsl(var(--surface));transition:border-color .2s,transform .2s;
}
.post-nav a:hover{border-color:hsl(var(--accent) / .5);transform:translateY(-2px)}
.post-nav .dir{font-size:.76rem;color:hsl(var(--muted));margin-bottom:.3rem}
.post-nav .t{font-size:.98rem;font-weight:700;line-height:1.5}
.post-nav a.next{text-align:left}
.post-nav a.disabled{visibility:hidden}

/* ---------- Footer ---------- */
footer.site{border-top:1px solid hsl(var(--border));padding:2.2rem 0 3rem;margin-top:2rem}
.footer-top{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:.8rem}
.footer-links{display:flex;flex-wrap:wrap;gap:1rem}
.footer-links a{font-size:.86rem;color:hsl(var(--muted));transition:color .18s}
.footer-links a:hover{color:hsl(var(--fg))}
.footer-social{display:flex;gap:.35rem}
.footer-social a{display:grid;place-items:center;width:32px;height:32px;border:1px solid hsl(var(--border));border-radius:8px;transition:background-color .18s,transform .18s}
.footer-social a:hover{background:hsl(var(--surface));transform:translateY(-2px)}
.footer-social svg{width:15px;height:15px}
.footer-social .icon-btn{width:32px;height:32px;border-radius:8px;margin:0}
.footer-note{font-size:.8rem;color:hsl(var(--muted));margin-top:1.1rem;opacity:.9}

.hidden{display:none !important}

@media (max-width:560px){
  .nav a{padding:.35rem .4rem;font-size:.85rem}
  .uses li{flex-direction:column;gap:.1rem}
  .uses .k{min-width:0}
  .nl-form{flex-direction:column}
  .post-nav{grid-template-columns:1fr}
  a.post{gap:.7rem}
}

@media (prefers-reduced-motion:reduce){
  *{scroll-behavior:auto}
  .js .reveal{animation:none;opacity:1}
}

/* Hugo: markdown blockquotes wrap text in <p> — keep the quote box tight */
.article-body blockquote p{margin:0}
