/* ============================================================
   E-INK PORTFOLIO — shared stylesheet
   personal edition · sketchbook flavour
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Caveat:wght@400;600;700&family=Fraunces:opsz,wght,SOFT@9..144,300..700,0..100&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --paper:        #f1ead8;
  --paper-shade:  #e6dcc4;
  --paper-deep:   #d8cfb3;
  --ink:          #2b2620;
  --ink-soft:     #5a5247;
  --ink-faint:    #8c8270;
  --rule:         #c9bfa5;
  --accent:       #a23a18; /* dried red ink */
  --accent-soft:  #c5704a;
  --accent-blue:  #4a6276; /* fountain-pen blue */
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  background-color: var(--paper);
  color: var(--ink);
  font-family: "Fraunces", "EB Garamond", Georgia, serif;
  font-weight: 380;
  font-size: 18px;
  line-height: 1.65;
  letter-spacing: 0.005em;
  background-image:
    radial-gradient(ellipse at 20% 10%, rgba(255,250,230,0.5), transparent 60%),
    radial-gradient(ellipse at 85% 90%, rgba(180,150,100,0.08), transparent 55%),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.16  0 0 0 0 0.14  0 0 0 0 0.12  0 0 0 0.06 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  background-attachment: fixed;
  min-height: 100vh;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed; inset: 0;
  background: radial-gradient(circle at var(--mx, 50%) var(--my, 30%),
              rgba(255,245,215,0.35), transparent 45%);
  pointer-events: none;
  z-index: 0;
  transition: background 0.6s ease;
}

main, header, footer, .wrap { position: relative; z-index: 1; }

.wrap {
  max-width: 920px;
  margin: 0 auto;
  padding: 64px 36px 96px;
  position: relative;
}
.wrap.narrow { max-width: 720px; }

/* ============================================================ TYPOGRAPHY */

h1, h2, h3, h4, h5, h6 { color: var(--ink); }

h1 {
  font-family: "Fraunces", serif;
  font-weight: 500;
  font-variation-settings: "SOFT" 50, "opsz" 144;
  letter-spacing: -0.02em;
  margin: 0 0 6px 0;
  line-height: 0.98;
}

h2 {
  font-family: "Fraunces", serif;
  font-weight: 400;
  font-style: italic;
  font-variation-settings: "SOFT" 100;
  font-size: 32px;
  letter-spacing: -0.01em;
  margin: 36px 0 10px;
}

h3 {
  font-family: "Fraunces", serif;
  font-weight: 500;
  font-size: 22px;
  margin: 24px 0 8px;
  letter-spacing: -0.005em;
}

p { margin: 0 0 16px; color: var(--ink-soft); }

a {
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid var(--ink-faint);
  padding-bottom: 1px;
  transition: color 0.2s, border-color 0.2s;
}
a:hover { color: var(--accent); border-color: var(--accent); }

strong { font-weight: 600; color: var(--ink); }
em { font-style: italic; }

ul, ol { color: var(--ink-soft); padding-left: 22px; margin: 0 0 18px; }
li { margin-bottom: 6px; }

blockquote {
  margin: 28px 0 22px;
  padding: 26px 0 6px 24px;
  border-left: 2px solid var(--accent-soft);
  font-style: italic;
  color: var(--ink-soft);
  position: relative;
}
blockquote::before {
  content: "❝";
  font-family: "Fraunces", serif;
  font-size: 30px;
  color: var(--accent);
  position: absolute;
  left: 14px; top: -4px;
  line-height: 1;
}

code {
  font-family: "JetBrains Mono", "SF Mono", Menlo, monospace;
  font-size: 0.88em;
  background: var(--paper-shade);
  padding: 1px 6px;
  border-radius: 2px;
  color: var(--ink);
}

pre {
  font-family: "JetBrains Mono", "SF Mono", Menlo, monospace;
  background: var(--paper-shade);
  padding: 16px 18px;
  border-radius: 3px;
  overflow-x: auto;
  font-size: 14px;
  line-height: 1.6;
  border: 1px solid var(--rule);
}
pre code { background: none; padding: 0; }

hr { border: none; border-top: 1px dashed var(--rule); margin: 32px 0; }

table { border-collapse: collapse; margin: 16px 0; width: 100%; }
th, td { border: 1px solid var(--rule); padding: 8px 12px; text-align: left; }
th { background: var(--paper-shade); font-weight: 600; }

/* ============================================================ SHARED ELEMENTS */

.stamp {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: "Caveat", cursive;
  font-weight: 600;
  font-size: 22px;
  color: var(--accent);
  letter-spacing: 0.02em;
  transform: rotate(-2deg);
  margin-bottom: 18px;
}
.stamp svg { width: 22px; height: 22px; }

.kicker {
  font-family: "Caveat", cursive;
  font-size: 22px;
  color: var(--ink-faint);
  margin: 0 0 6px 0;
  display: block;
}
.kicker .crumb { color: var(--accent-soft); }

.tagline {
  font-family: "Caveat", cursive;
  font-size: 30px;
  font-weight: 600;
  color: var(--ink-soft);
  margin: 0 0 24px 0;
  transform: rotate(-0.6deg);
  display: inline-block;
}

.signature {
  font-family: "Caveat", cursive;
  font-weight: 600;
  font-size: 26px;
  color: var(--accent);
  transform: rotate(-3deg);
  transform-origin: bottom left;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: "Caveat", cursive;
  font-weight: 600;
  font-size: 22px;
  color: var(--accent);
  text-decoration: none;
  border: none;
  transform: rotate(-1deg);
  margin-bottom: 28px;
}
.back-link:hover { color: var(--ink); border: none; }
.back-link svg { width: 20px; height: 14px; }

.underline-doodle { display: block; margin: -10px 0 28px 4px; max-width: 280px; }
.underline-doodle.long { max-width: 420px; }

/* ============================================================ MARGINALIA */

.marginalia {
  font-family: "Caveat", cursive;
  font-size: 19px;
  font-weight: 600;
  color: var(--ink-faint);
  font-style: italic;
  line-height: 1.3;
  position: absolute;
  pointer-events: none;
  max-width: 180px;
  z-index: 2;
}
.marginalia svg { display: block; margin-top: 2px; }
.marginalia.tilt-l { transform: rotate(-3deg); }
.marginalia.tilt-r { transform: rotate(2.5deg); }

@media (max-width: 1080px) {
  .marginalia { display: none; }
}

/* ============================================================ WAX SEAL */

.wax-seal {
  position: absolute;
  pointer-events: none;
  filter: drop-shadow(1px 2px 0 rgba(80, 30, 10, 0.18));
}
.wax-seal text {
  font-family: "Fraunces", serif;
  font-weight: 500;
  font-style: italic;
  fill: var(--paper);
}

/* ============================================================ FLOURISH DIVIDERS */

.flourish {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  margin: 64px 0 36px;
  color: var(--ink-faint);
}
.flourish.tight { margin: 40px 0 24px; }
.flourish svg { display: block; }
.flourish .ast {
  font-family: "Fraunces", serif;
  font-style: italic;
  font-size: 28px;
  color: var(--accent);
}

/* ============================================================ INDEX PAGE */

h1.title {
  font-size: clamp(64px, 12vw, 124px);
  letter-spacing: -0.04em;
}
h1.title .dot { color: var(--accent); font-style: italic; font-weight: 300; }

.intro {
  max-width: 580px;
  font-size: 19px;
  line-height: 1.75;
  color: var(--ink-soft);
  margin: 28px 0 0;
  font-style: italic;
}
.intro::first-letter {
  font-family: "Fraunces", serif;
  font-style: italic;
  font-weight: 400;
  font-size: 4.2em;
  font-variation-settings: "SOFT" 100, "opsz" 144;
  color: var(--accent);
  float: left;
  line-height: 0.82;
  margin: 6px 12px -4px 0;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 24px;
  margin: 56px 0 28px;
  flex-wrap: wrap;
}
.section-head h2 { margin: 0; font-size: 38px; }
.section-meta { font-family: "Caveat", cursive; color: var(--ink-faint); font-size: 22px; }

.apps {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 28px;
}

.card {
  position: relative;
  padding: 28px 26px 24px;
  background: rgba(255, 250, 232, 0.35);
  border: 1.5px solid var(--ink);
  border-radius: 2px;
  box-shadow: 4px 4px 0 -1px var(--ink-soft);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.card:nth-child(odd)  { transform: rotate(-0.4deg); }
.card:nth-child(even) { transform: rotate(0.3deg); }
.card:hover {
  transform: rotate(0deg) translate(-2px, -2px);
  box-shadow: 7px 7px 0 -1px var(--ink-soft);
}

.card .doodle-mark {
  position: absolute;
  top: -14px; right: 18px;
  background: var(--paper);
  padding: 0 8px;
}
.card .doodle-mark svg { width: 28px; height: 28px; display: block; }

.card .corner-flourish {
  position: absolute;
  top: 6px; left: 6px;
  width: 22px; height: 22px;
  pointer-events: none;
  opacity: 0.65;
}

.card h3 { font-size: 26px; margin: 0 0 6px 0; }
.card .kicker { color: var(--accent); font-size: 19px; margin-bottom: 10px; }
.card p { margin: 0 0 18px 0; font-size: 16px; line-height: 1.6; }

.card-links {
  display: flex; flex-wrap: wrap; gap: 16px; align-items: center; font-size: 14px;
}
.card-links a { color: var(--ink); border-bottom: 1px solid var(--ink-faint); }
.card-links a:hover { color: var(--accent); border-color: var(--accent); }
.card-links a.primary {
  font-family: "Caveat", cursive;
  font-weight: 600;
  font-size: 20px;
  border: none;
  color: var(--accent);
  margin-right: 4px;
}
.card-links a.primary::after { content: " ↗"; }
.card-links .sep { color: var(--ink-faint); font-size: 12px; user-select: none; }

.card.placeholder {
  border-style: dashed;
  background: transparent;
  color: var(--ink-faint);
  text-align: center;
  display: flex; flex-direction: column;
  justify-content: center; align-items: center;
  min-height: 200px; gap: 10px;
}
.card.placeholder .desk-doodle { width: 90px; opacity: 0.55; }
.card.placeholder span { font-family: "Caveat", cursive; font-size: 24px; }

.columns {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 56px;
  margin-top: 8px;
}
.columns p { margin: 0 0 14px; }

.scratch-list { list-style: none; padding: 0; margin: 0; }
.scratch-list li {
  padding: 10px 0;
  border-bottom: 1px dashed var(--rule);
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 0;
  align-items: center;
}
.scratch-list li:last-child { border-bottom: none; }
.scratch-list a { color: var(--ink); border-bottom: 1px solid transparent; }
.scratch-list a:hover { border-bottom-color: var(--accent); color: var(--accent); }
.scratch-list .label {
  font-family: "Caveat", cursive;
  color: var(--ink-faint);
  font-size: 19px;
  display: flex; align-items: center; gap: 6px;
}
.scratch-list .label svg { width: 18px; height: 18px; opacity: 0.7; }

/* ============================================================ DOC PAGES */

.doc h1 { font-size: clamp(40px, 6vw, 60px); }
.doc-meta {
  color: var(--ink-faint);
  font-size: 15px;
  margin: 8px 0 28px;
  border-bottom: 1px dashed var(--rule);
  padding-bottom: 16px;
}
.doc-meta strong { color: var(--ink-soft); font-weight: 500; }

.doc-content { font-size: 17px; line-height: 1.8; }
.doc-content > :first-child { margin-top: 0; }

.doc-content > p:first-of-type::first-letter {
  font-family: "Fraunces", serif;
  font-weight: 500;
  font-variation-settings: "SOFT" 100, "opsz" 144;
  font-size: 4em;
  color: var(--accent);
  float: left;
  line-height: 0.85;
  margin: 8px 10px -2px 0;
}

.doc-content h2::before {
  content: "§ ";
  color: var(--accent);
  font-style: normal;
  font-weight: 400;
}
.doc-content h2 { margin-top: 44px; font-size: 28px; }
.doc-content h3 { margin-top: 28px; }

.doc-content ul li::marker { content: "❦  "; color: var(--accent-soft); }

.doc-loading {
  font-family: "Caveat", cursive;
  font-size: 22px;
  color: var(--ink-faint);
  text-align: center;
  padding: 40px 0;
}

.doc-error {
  border: 1.5px dashed var(--accent);
  padding: 16px 20px;
  border-radius: 2px;
  color: var(--accent);
  font-size: 15px;
  margin: 24px 0;
}
.doc-error code { background: rgba(162, 58, 24, 0.08); }

/* ============================================================ APP PAGES */

.app-hero { margin-bottom: 32px; position: relative; }
.app-hero h1 { font-size: clamp(44px, 7vw, 72px); }

.app-links-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin: 32px 0;
}

.app-link {
  display: block;
  padding: 18px 20px;
  border: 1.5px solid var(--ink);
  background: rgba(255, 250, 232, 0.35);
  text-decoration: none;
  color: var(--ink);
  border-radius: 2px;
  box-shadow: 3px 3px 0 -1px var(--ink-soft);
  transition: all 0.2s ease;
  position: relative;
}
.app-link:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: translate(-2px, -2px);
  box-shadow: 5px 5px 0 -1px var(--ink-soft);
}
.app-link .label {
  font-family: "Caveat", cursive;
  font-size: 18px;
  color: var(--ink-faint);
  display: block;
  margin-bottom: 2px;
}
.app-link .name {
  font-family: "Fraunces", serif;
  font-weight: 500;
  font-size: 20px;
}
.app-link.external .name::after { content: " ↗"; color: var(--accent); }

/* ============================================================ FOOTER */

footer {
  margin-top: 80px;
  padding-top: 28px;
  border-top: 1px solid var(--rule);
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
  flex-wrap: wrap;
  color: var(--ink-faint);
  font-size: 14px;
  position: relative;
}
footer a { color: var(--ink-faint); border-bottom-color: transparent; }
footer a:hover { color: var(--accent); border-bottom-color: var(--accent); }

/* ============================================================ ANIMATIONS */

@keyframes ink-bloom {
  from { opacity: 0; transform: translateY(8px); filter: blur(2px); }
  to   { opacity: 1; transform: translateY(0);   filter: blur(0); }
}
@keyframes flock-drift {
  0%   { transform: translate(0, 0); }
  50%  { transform: translate(-3px, -2px); }
  100% { transform: translate(0, 0); }
}
@keyframes seal-press {
  from { opacity: 0; transform: scale(0.7) rotate(-8deg); }
  to   { opacity: 1; transform: scale(1)   rotate(-12deg); }
}

.ink-in   { animation: ink-bloom 0.9s cubic-bezier(.2,.7,.2,1) both; }
.ink-in-1 { animation-delay: 0.05s; }
.ink-in-2 { animation-delay: 0.20s; }
.ink-in-3 { animation-delay: 0.35s; }
.ink-in-4 { animation-delay: 0.50s; }
.ink-in-5 { animation-delay: 0.65s; }
.ink-in-6 { animation-delay: 0.80s; }

.flock { animation: flock-drift 9s ease-in-out infinite; }
.seal-in { animation: seal-press 1s cubic-bezier(.2,.9,.3,1.2) 0.6s both; }

/* ============================================================ RESPONSIVE */

@media (max-width: 720px) {
  body { font-size: 17px; }
  .wrap { padding: 40px 22px 64px; }
  .apps, .columns { grid-template-columns: 1fr; gap: 28px; }
  h1.title { font-size: 72px; }
  .section-head h2 { font-size: 30px; }
  .wax-seal { width: 60px !important; height: 60px !important; }
}
