/*
  Background pattern adapted from "Terrazzo Fragment Background"
  by Opensource UI (https://opensourceui.in), MIT licence.
  Rewritten here as plain CSS; colours and fragment layout follow the original.
*/

:root {
  --bg: #F3F0EA;
  --ink: #1b1a17;
  --muted: #5f5a52;
  --line: #d9d3c7;
  --accent: #0b6b63;            /* deepened from the terrazzo teal */
  --panel: rgba(255, 255, 255, 0.72);
  --max: 920px;
  --pad: 24px;                  /* left padding of the content column */
  --serif: ui-serif, "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

img { display: block; max-width: 100%; height: auto; }
a { color: inherit; }

/* ---------- terrazzo background ---------- */
.terrazzo {
  position: fixed; inset: 0; z-index: -1; pointer-events: none; overflow: hidden;
  background:
    radial-gradient(circle at center, rgba(87, 83, 78, 0.05) 1px, transparent 1px) 0 0 / 4px 4px,
    linear-gradient(180deg, #FAF8F4 0%, #EEE8DF 100%);
}
.terrazzo i { position: absolute; display: block; filter: opacity(.6); }
.terrazzo i:nth-child(1)  { top: 12%;    left: 8%;   width: 64px; height: 40px; transform: rotate(-18deg); border-radius: 6px;  background: #D9C4A9; opacity: .80; }
.terrazzo i:nth-child(2)  { top: 30%;    left: 4%;   width: 32px; height: 32px; transform: rotate(24deg);  border-radius: 50%;  background: #F43F5E; opacity: .35; }
.terrazzo i:nth-child(3)  { top: 10%;    right: 18%; width: 80px; height: 48px; transform: rotate(12deg);  border-radius: 8px;  background: #99F6E4; opacity: .55; }
.terrazzo i:nth-child(4)  { top: 42%;    left: 14%;  width: 40px; height: 56px; transform: rotate(36deg);  border-radius: 6px;  background: #A8A29E; opacity: .55; }
.terrazzo i:nth-child(5)  { top: 36%;    right: 12%; width: 48px; height: 64px; transform: rotate(-28deg); border-radius: 8px;  background: #FCD34D; opacity: .45; }
.terrazzo i:nth-child(6)  { bottom: 28%; left: 42%;  width: 56px; height: 36px; transform: rotate(-8deg);  border-radius: 6px;  background: #2DD4BF; opacity: .40; }
.terrazzo i:nth-child(7)  { bottom: 18%; left: 10%;  width: 36px; height: 48px; transform: rotate(42deg);  border-radius: 8px;  background: #D6D3D1; opacity: .70; }
.terrazzo i:nth-child(8)  { bottom: 14%; right: 24%; width: 64px; height: 40px; transform: rotate(-14deg); border-radius: 6px;  background: #FB923C; opacity: .40; }
.terrazzo i:nth-child(9)  { bottom: 34%; right: 8%;  width: 32px; height: 32px; transform: rotate(16deg);  border-radius: 50%;  background: #78716C; opacity: .45; }
.terrazzo i:nth-child(10) { top: 58%;    left: 58%;  width: 28px; height: 44px; transform: rotate(30deg);  border-radius: 6px;  background: #5EEAD4; opacity: .35; }

/* ---------- header ---------- */
.skip {
  position: absolute; left: 12px; top: -48px;
  background: var(--ink); color: #fff;
  padding: 8px 12px; border-radius: 6px; z-index: 20;
}
.skip:focus { top: 12px; }

.top { position: sticky; top: 0; z-index: 10; background: rgba(243, 240, 234, 0.9); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); border-bottom: 1px solid var(--line); }
.nav {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 6px 24px;
  max-width: var(--max); margin: 0 auto; padding: 14px 24px;
}
.brand { font-family: var(--serif); font-size: 1.15rem; font-weight: 700; text-decoration: none; letter-spacing: -0.01em; }
.nav nav { display: flex; flex-wrap: wrap; gap: 2px 18px; }
.nav nav a { color: var(--muted); text-decoration: none; font-size: 0.95rem; padding: 2px 0; border-bottom: 2px solid transparent; }
.nav nav a:hover, .nav nav a:focus-visible { color: var(--ink); border-bottom-color: var(--accent); }

/* ---------- the dotted trail (drawn by the script at the end of index.html) ---------- */
main { position: relative; display: block; }
.thread {
  position: relative; z-index: 1;
  max-width: var(--max); margin: 0 auto;
  padding: 0 24px 40px var(--pad);
}
.doodle {
  position: absolute; left: 0; top: 0; z-index: 0;
  width: 100%; height: 100%;
  overflow: visible; pointer-events: none;
  color: var(--ink);
}
section.knot { position: relative; scroll-margin-top: 72px; padding-bottom: 150px; }
section.knot:last-child { padding-bottom: 24px; }

/* ---------- type ---------- */
h1, h2, h3 { font-family: var(--serif); font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; }
h1 { margin: 0 0 14px; font-size: clamp(2.2rem, 6vw, 3.6rem); letter-spacing: -0.035em; }
h2 { margin: 0 0 24px; font-size: 1.9rem; }
h3 { margin: 0; font-size: 1.45rem; }
.lead { margin: 0; max-width: 40ch; font-family: var(--serif); font-size: clamp(1.05rem, 2.4vw, 1.3rem); line-height: 1.45; color: var(--muted); }

/* ---------- links and buttons ---------- */
.link {
  color: var(--accent); text-decoration: underline; text-decoration-color: rgba(11, 107, 99, .35);
  text-underline-offset: 3px; font-weight: 550;
}
.link:hover, .link:focus-visible { text-decoration-color: var(--accent); }

.actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 22px 0 0; }
.btn {
  display: inline-block; padding: 10px 18px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--panel); text-decoration: none; font-size: 0.95rem;
  transition: border-color 0.2s;
}
.btn:hover, .btn:focus-visible { border-color: var(--ink); }
.btn.primary { background: var(--ink); color: #fff; border-color: var(--ink); }

/* ---------- home ---------- */
.intro { display: flex; align-items: center; gap: 32px; padding-top: 40px; }
.arch {
  flex: none; width: 168px; height: 224px; object-fit: cover; object-position: 50% 30%;
  border-radius: 999px 999px 18px 18px; border: 1px solid var(--line); background: #d8d2c6;
}

/* ---------- projects: preview left, text right ---------- */
.project { display: grid; grid-template-columns: 1.3fr 1fr; gap: 28px; align-items: center; margin-bottom: 44px; }
.project:last-child { margin-bottom: 0; }
.frame {
  display: block; text-decoration: none; overflow: hidden; background: #fff;
  border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 24px 48px -32px rgba(70, 55, 30, .45);
  transition: transform .25s ease, box-shadow .25s ease;
}
.frame:hover, .frame:focus-visible { transform: translateY(-3px); box-shadow: 0 30px 56px -30px rgba(70, 55, 30, .55); }
.frame-bar { display: flex; align-items: center; gap: 6px; padding: 9px 12px; background: #faf8f4; border-bottom: 1px solid var(--line); }
.frame-bar i { width: 9px; height: 9px; border-radius: 50%; background: #D9C4A9; }
.frame-bar i:nth-child(2) { background: #99F6E4; }
.frame-bar i:nth-child(3) { background: #FCD34D; }
.frame-bar b { margin-left: 8px; font-size: 0.75rem; font-weight: 500; color: var(--muted); }
.frame img { width: 100%; height: auto; }
.project-text p { margin: 8px 0 0; }
.project-text .result { font-weight: 600; }
.project-text p:not(.result):not(.links) { color: var(--muted); }
.project-text .links { display: flex; flex-wrap: wrap; gap: 4px 18px; margin-top: 12px; }
.project-text .tags { margin-top: 12px; }
.tag {
  display: inline-block; font-size: 0.78rem; color: var(--muted);
  padding: 2px 10px; border: 1px solid var(--line); border-radius: 999px;
  background: rgba(255, 255, 255, 0.6);
}

/* ---------- blog, about ---------- */
.empty { max-width: 460px; padding: 22px 26px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; }
.empty h3 { font-size: 1.25rem; margin-bottom: 6px; }
.empty p { margin: 0; color: var(--muted); }
.about-text { margin: 0 0 14px; max-width: 54ch; font-size: 1.05rem; }

/* ---------- galleries ---------- */
.gallery { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; grid-template-columns: repeat(2, 1fr); }
.gallery li { margin: 0; }
.gallery img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 14px; background: #fff; }
.gallery span { display: block; margin-top: 6px; font-size: 0.85rem; color: var(--muted); }
.gallery a.zoom { display: block; cursor: zoom-in; border-radius: 14px; }
.gallery a.zoom img { transition: transform .25s ease, box-shadow .25s ease; }
.gallery a.zoom:hover img, .gallery a.zoom:focus-visible img { transform: translateY(-2px); box-shadow: 0 18px 36px -22px rgba(70, 55, 30, .6); }

/* ---------- photo viewer ---------- */
dialog#viewer {
  width: 100vw; max-width: none; height: 100vh; max-height: none; margin: 0; padding: 0;
  border: 0; background: transparent; color: #fff; overflow: hidden;
}
dialog#viewer[open] { display: flex; align-items: center; justify-content: center; gap: 12px; }
dialog#viewer::backdrop { background: rgba(27, 26, 23, 0.78); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
dialog#viewer figure { margin: 0; text-align: center; }
dialog#viewer img { max-width: min(88vw, 720px); max-height: 82vh; width: auto; height: auto; border-radius: 14px; background: #fff; }
dialog#viewer .cap { margin-top: 10px; font-size: 0.95rem; color: rgba(255, 255, 255, 0.9); }
.vbtn {
  flex: none; width: 44px; height: 44px; border-radius: 50%; border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.14); color: #fff; font: inherit; font-size: 1.6rem; line-height: 1; cursor: pointer;
}
.vbtn:hover, .vbtn:focus-visible { background: rgba(255, 255, 255, 0.28); outline: 2px solid #fff; outline-offset: 2px; }
.vbtn.close { position: absolute; top: 16px; right: 16px; }
dialog#viewer.single .prev, dialog#viewer.single .next { display: none; }
@media (max-width: 560px) {
  dialog#viewer[open] { gap: 4px; }
  .vbtn { width: 38px; height: 38px; }
}

/* ---------- footer ---------- */
.foot {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px;
  max-width: var(--max); margin: 0 auto; padding: 24px 24px 40px;
  border-top: 1px solid var(--line); font-size: 0.82rem; color: var(--muted);
}

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

@media (min-width: 768px) {
  .gallery { grid-template-columns: repeat(4, 1fr); }
  .gallery.two { grid-template-columns: repeat(2, minmax(0, 300px)); }
}

@media (max-width: 760px) {
  :root { --pad: 16px; }
  .project { grid-template-columns: 1fr; gap: 16px; }
}

@media (max-width: 560px) {
  .thread { padding-right: 16px; }
  .intro { flex-direction: column; align-items: flex-start; gap: 20px; }
  .arch { width: 132px; height: 176px; }
  h2 { font-size: 1.6rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; animation: none !important; }
}
