/*
 * prawees.com base styles: fonts, tokens, header bar, grid, ambient frame, dithered images.
 * Page layouts live in site.css (home, gallery) and theme.css (older pages).
 *
 * Typeface: Arimo (a plain Helvetica-style grotesque) for Latin, IBM Plex Sans Thai for Thai.
 *           Both are self-hosted in assets/fonts. To change the face, edit --sans.
 * Sizes:    14 / 17 / --fs-h / --fs-hero. Hierarchy by size and weight only.
 * Colour:   #111 ink, #595959 and #E5E5E5 greys, white, plus one accent per project and per platform.
 * Grid:     4 columns on a phone, 12 from 768px. Content starts at column 4 beside a label rail.
 */

@font-face { font-family: "Arimo"; font-weight: 400; font-style: normal; font-display: swap; src: url("fonts/arimo-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Arimo"; font-weight: 700; font-style: normal; font-display: swap; src: url("fonts/arimo-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans Thai"; font-weight: 400; font-style: normal; font-display: swap; src: url("fonts/ibm-plex-sans-thai-thai-400-normal.woff2") format("woff2"); unicode-range: U+0E01-0E5B, U+200B-200D, U+25CC; }
@font-face { font-family: "IBM Plex Sans Thai"; font-weight: 700; font-style: normal; font-display: swap; src: url("fonts/ibm-plex-sans-thai-thai-600-normal.woff2") format("woff2"); unicode-range: U+0E01-0E5B, U+200B-200D, U+25CC; }

@font-face { font-family: "Mali"; font-weight: 400; font-style: normal; font-display: swap; src: url("fonts/mali-latin-400-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215; }
@font-face { font-family: "Mali"; font-weight: 400; font-style: normal; font-display: swap; src: url("fonts/mali-thai-400-normal.woff2") format("woff2"); unicode-range: U+0E01-0E5B, U+200B-200D, U+25CC; }

:root {
  --paper: #fff;
  --ink: #111;
  --mid: #595959;
  --light: #e5e5e5;

  --sans: "Arimo", "Helvetica Neue", Helvetica, Arial, "IBM Plex Sans Thai", "Thonburi", "Leelawadee UI", sans-serif;

  --fs-s: 14px;
  --fs-b: 17px;
  --fs-h: clamp(28px, 4vw, 48px);
  --fs-hero: clamp(32px, 9vw, 120px);

  --gap: 16px;
  --pad: max(20px, env(safe-area-inset-left));
  --padr: max(20px, env(safe-area-inset-right));
  --max: 1200px;

  /* 4x4 Bayer fills, used by the cycling word and by hovered project titles */
  --d8w: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='4' height='4' shape-rendering='crispEdges'%3E%3Cpath fill='%23f2f2f2' d='M0 0h1v1h-1zM2 0h1v1h-1zM1 1h1v1h-1zM3 1h1v1h-1zM0 2h1v1h-1zM2 2h1v1h-1zM1 3h1v1h-1zM3 3h1v1h-1z'/%3E%3C/svg%3E");
  --d12w: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='4' height='4' shape-rendering='crispEdges'%3E%3Cpath fill='%23f2f2f2' d='M0 0h1v1h-1zM1 0h1v1h-1zM2 0h1v1h-1zM3 0h1v1h-1zM1 1h1v1h-1zM3 1h1v1h-1zM0 2h1v1h-1zM1 2h1v1h-1zM2 2h1v1h-1zM3 2h1v1h-1zM1 3h1v1h-1zM3 3h1v1h-1z'/%3E%3C/svg%3E");
  --d5w: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='4' height='4' shape-rendering='crispEdges'%3E%3Cpath fill='%23f2f2f2' d='M0 0h1v1h-1zM2 0h1v1h-1zM1 1h1v1h-1zM0 2h1v1h-1zM2 2h1v1h-1z'/%3E%3C/svg%3E");
  --d2w: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='4' height='4' shape-rendering='crispEdges'%3E%3Cpath fill='%23f2f2f2' d='M0 0h1v1h-1zM2 2h1v1h-1z'/%3E%3C/svg%3E");
  --d12: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='4' height='4' shape-rendering='crispEdges'%3E%3Cpath fill='%23111' d='M0 0h1v1h-1zM1 0h1v1h-1zM2 0h1v1h-1zM3 0h1v1h-1zM1 1h1v1h-1zM3 1h1v1h-1zM0 2h1v1h-1zM1 2h1v1h-1zM2 2h1v1h-1zM3 2h1v1h-1zM1 3h1v1h-1zM3 3h1v1h-1z'/%3E%3C/svg%3E");
  --d8: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='4' height='4' shape-rendering='crispEdges'%3E%3Cpath fill='%23111' d='M0 0h1v1h-1zM2 0h1v1h-1zM1 1h1v1h-1zM3 1h1v1h-1zM0 2h1v1h-1zM2 2h1v1h-1zM1 3h1v1h-1zM3 3h1v1h-1z'/%3E%3C/svg%3E");
  --d5: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='4' height='4' shape-rendering='crispEdges'%3E%3Cpath fill='%23111' d='M0 0h1v1h-1zM2 0h1v1h-1zM1 1h1v1h-1zM0 2h1v1h-1zM2 2h1v1h-1z'/%3E%3C/svg%3E");
  --d2: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='4' height='4' shape-rendering='crispEdges'%3E%3Cpath fill='%23111' d='M0 0h1v1h-1zM2 2h1v1h-1z'/%3E%3C/svg%3E");
}

/* the gallery ends in a dithered fade to black (assets/dither.js adds .night once it is dark enough to read light text) */
html.night { --paper: #0b0b0b; --ink: #f2f2f2; --mid: #a6a6a6; --light: #2a2a2a; }

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

html { scroll-padding-top: 96px; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; background: var(--paper); }

body {
  background: transparent;           /* lets the fixed ambient frame show through */
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--fs-b);
  font-weight: 400;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  min-height: 100svh;
}

a { color: var(--ink); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; text-decoration-color: var(--mid); }
a:hover { text-decoration-color: var(--ink); }
a:focus-visible, button:focus-visible, .dz:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
img { max-width: 100%; height: auto; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

/* ---------- ambient frame ---------- */
.amb { position: fixed; top: 0; left: 0; width: 100%; height: 100vh; height: 100lvh; z-index: -1; background: var(--paper); pointer-events: none; }
.amb canvas { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; image-rendering: crisp-edges; opacity: 0; transition: opacity .8s steps(8, end); }
.amb.ready canvas { opacity: 1; }

/* ---------- layout ---------- */
.g {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  column-gap: 12px;
  width: 100%;
  max-width: var(--max);
  margin: 0 auto;
  padding-left: var(--pad);
  padding-right: var(--padr);
}
@media (min-width: 768px) { .g { grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: var(--gap); } }

/* ---------- bar ---------- */
.bar { position: -webkit-sticky; position: sticky; top: 0; background: var(--paper); border-bottom: 1px solid var(--ink); padding-top: env(safe-area-inset-top); z-index: 50; }
.bar .g { align-items: center; row-gap: 0; }
.brand { grid-row: 1; grid-column: 1 / 3; font-weight: 700; text-decoration: none; padding: 8px 0; letter-spacing: -.01em; }
.tools { grid-row: 1; grid-column: 3 / 5; justify-self: end; display: flex; align-items: center; gap: 4px; font-size: var(--fs-s); }
.nav { grid-row: 2; grid-column: 1 / 5; display: flex; gap: 22px; font-size: var(--fs-s); padding-bottom: 2px; }
.nav a { text-decoration: none; color: var(--mid); }
/* "hi, i'm Smart" sits in the bar's empty space once the big greeting has scrolled away */
.hi { grid-row: 2; grid-column: 3 / 5; justify-self: end; align-self: center; white-space: nowrap; pointer-events: none; font-size: var(--fs-b); line-height: 1.2; letter-spacing: -.01em; color: var(--mid); opacity: 0; visibility: hidden; transition: opacity .35s ease, visibility 0s .35s; }
.hi b { color: var(--ink); font-weight: 700; transition: color .5s ease; }
.hi.on { opacity: 1; visibility: visible; transition: opacity .35s ease; }
@media (min-width: 768px) { .hi { grid-row: 1; grid-column: 7 / 10; justify-self: start; } }
@media (max-width: 359px) { .hi { display: none; } }
@media (prefers-reduced-motion: reduce) { .hi, .hi.on, .hi b { transition: none; } }
.nav a:hover, .nav a[aria-current] { color: var(--ink); }
.nav a[aria-current] { text-decoration: underline; text-decoration-color: var(--ink); }
.tools button { padding: 12px 6px; color: var(--mid); min-height: 44px; }
.tools button:hover, .tools button.active, .tools button[aria-pressed="true"] { color: var(--ink); }
.tools button.active { text-decoration: underline; text-underline-offset: 3px; }
.tools .sep { color: var(--light); }
.tools .tog { white-space: nowrap; border: 1px solid var(--ink); margin-left: 8px; padding: 0 10px; min-height: 32px; color: var(--ink); }
.tools .tog[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
@media (min-width: 768px) {
  .brand { grid-column: 1 / 4; }
  .nav { grid-row: 1; grid-column: 4 / 9; padding: 0; gap: 22px; }
  .tools { grid-column: 9 / 13; }
  .tools button { padding: 8px 6px; min-height: 0; }
  .tools .tog { min-height: 28px; }
}
@media (pointer: coarse) {
  .tools button { min-height: 40px; min-width: 40px; padding-top: 8px; padding-bottom: 8px; }
  .tools .tog { min-height: 36px; }
  .nav a { padding: 8px 0; }
}

/* ---------- dithered photographs (inside the page) ---------- */
.dz { position: relative; display: block; overflow: hidden; background: var(--light); line-height: 0; -webkit-tap-highlight-color: transparent; }
.dz-img { display: block; width: 100%; height: auto; }
.dz-c { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; image-rendering: crisp-edges; opacity: 0; }
.dz.ready .dz-img { opacity: 0; }
.dz.ready .dz-c { opacity: 1; }
.dz.dev .dz-img, html.colour .dz .dz-img { opacity: 1; }
.dz.dev .dz-c, html.colour .dz .dz-c { opacity: 0; }
@media (hover: hover) { .dz:hover .dz-img { opacity: 1; } .dz:hover .dz-c { opacity: 0; } }
.dz.ready .dz-img, .dz-c { transition: opacity .3s steps(5, end); }
.dz.scan .dz-c { animation: dz-clip 1.1s steps(28, end) both; }
.dz.scan::after { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 2px; background: var(--ink); animation: dz-beam 1.1s steps(28, end) both; pointer-events: none; }
@keyframes dz-clip { from { clip-path: inset(0 0 100% 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes dz-beam { 0% { top: 0; opacity: 1; } 96% { opacity: 1; } 100% { top: calc(100% - 2px); opacity: 0; } }

/* ---------- reduced motion, print ---------- */
@media (prefers-reduced-motion: reduce) {
  .dz.scan .dz-c, .dz.scan::after { animation: none; }
  .dz.scan::after { display: none; }
  .dz.ready .dz-img, .dz-c, .amb canvas { transition: none; }
  .tw-typing::after, .foot .cur::after { animation: none; }
}
@media print { .amb { display: none; } }

/* ---------- section headings: set in dither, large, faint, on alternating sides ----------
   The same device as the gallery's chapter names. Used for the home page sections and the about page sections. */
.hd { grid-column: 1 / -1; justify-self: start; font-size: clamp(34px, 7vw, 72px); font-weight: 700; line-height: 1; letter-spacing: -.04em; padding-bottom: .08em; opacity: .42;
  color: transparent; -webkit-text-fill-color: transparent; background-image: var(--d8); background-size: 4px 4px; -webkit-background-clip: text; background-clip: text; image-rendering: pixelated; }
.hd.r { justify-self: end; text-align: right; }
html.night .hd { background-image: var(--d8w); }

/* ---------- closing quote: three lines, each set in a thinner dither than the last, like eyes closing ---------- */
.quote { --q1: var(--d12); --q2: var(--d5); font-weight: 700; letter-spacing: -.035em; line-height: 1.12; font-size: clamp(34px, 8.5vw, 104px); }
html.night .quote { --q1: var(--d12w); --q2: var(--d5w); }
.quote span { display: block; width: fit-content; max-width: 100%; color: transparent; -webkit-text-fill-color: transparent; -webkit-background-clip: text; background-clip: text; background-size: 4px 4px; image-rendering: pixelated; }
.quote .q1 { background-image: var(--q1); }
.quote .q2 { background-image: var(--q2); margin-left: 1.4em; }
.quote .q3 { margin-left: 2.8em; font-size: .3em; letter-spacing: .02em; margin-top: 1.1em; font-weight: 400; color: var(--mid); -webkit-text-fill-color: var(--mid); background: none; opacity: .8; }
