/*
  index.html / index-th.html: a "blueprint" look. Thin lines, dotted gutters, dashed boxes with corner
  handles, small mono labels. Dark is the normal look; js/darkmode.js adds .light-theme.
*/

:root {
  --bg: #08090a;
  --panel: #0c0d0f;
  --line: #24262b; /* full lines */
  --line-2: #33363d; /* dashed lines, box borders */
  /* dashes: 6px long, 6px apart. One image per theme because a url() cannot read the color variables */
  --dash-img: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' shape-rendering='crispEdges' fill='%2333363d'><rect x='1' y='0' width='6' height='1'/><rect x='1' y='13' width='6' height='1'/><rect x='0' y='1' width='1' height='6'/><rect x='13' y='1' width='1' height='6'/><rect x='0' y='0' width='1' height='1'/><rect x='13' y='0' width='1' height='1'/><rect x='0' y='13' width='1' height='1'/><rect x='13' y='13' width='1' height='1'/></svg>");
  --dot: #23252a;
  --txt: #f4f4f5;
  --muted: #9a9ca3;
  --faint: #62656d;
  --accent: #56ccff;
  --accent-ink: #001018;
  --hover: rgba(255, 255, 255, 0.035);

  --pink: #ff2775;
  --grey: #8b9494;
  --purple: #c46ae0;
  --green: #5cc045;

  --sans: Inter, "Noto Sans Thai", Arial, sans-serif;
  --mono:
    "JetBrains Mono", "Noto Sans Thai", ui-monospace, SFMono-Regular, Menlo,
    Consolas, monospace;
}

.light-theme {
  --bg: #eeeeea;
  --panel: #f9f9f7;
  --line: #cfcfc8;
  --line-2: #b9b9b1;
  --dash-img: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' shape-rendering='crispEdges' fill='%23b9b9b1'><rect x='1' y='0' width='6' height='1'/><rect x='1' y='13' width='6' height='1'/><rect x='0' y='1' width='1' height='6'/><rect x='13' y='1' width='1' height='6'/><rect x='0' y='0' width='1' height='1'/><rect x='13' y='0' width='1' height='1'/><rect x='0' y='13' width='1' height='1'/><rect x='13' y='13' width='1' height='1'/></svg>");
  --dot: #d3d3cb;
  --txt: #101113;
  --muted: #55575c;
  --faint: #8a8c91;
  --accent: #0699d9;
  --accent-ink: #ffffff;
  --hover: rgba(0, 0, 0, 0.035);

  --pink: #d6125c;
  --grey: #5f6868;
  --purple: #9a35bd;
  --green: #2f8f1c;
}

/* ---------- base ---------- */

html {
  scroll-behavior: smooth;
  scroll-padding-top: 20px;
}
::selection {
  color: var(--bg);
  background: var(--txt);
}
::-webkit-scrollbar {
  width: 0.5em;
}
::-webkit-scrollbar-track {
  background: var(--bg);
}
::-webkit-scrollbar-thumb {
  background: var(--line-2);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}
body {
  margin: 0;
  color: var(--txt);
  font-family: var(--sans);
  background-color: var(--bg);
  transition: background-color 300ms;
}
a {
  color: inherit;
  text-decoration: none;
}
h1,
h2,
h3,
p {
  margin: 0;
}
/* mainh.css gives h2 / h3 a fixed font and a fixed light color; use the page's own instead */
h1,
h2,
h3 {
  font-family: var(--sans);
  color: inherit;
}
.mono {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ---------- page structure: full-width lines, a framed column in the middle ---------- */

.band {
  border-top: 1px solid var(--line);
}
.band:last-of-type {
  border-bottom: 1px solid var(--line);
}
.frame {
  position: relative;
  box-sizing: border-box;
  max-width: 1040px;
  margin: 0 auto;
  background-color: var(--panel);
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
}
/* the last frame closes with a handle on each bottom corner, like the corners of a box */
.band:last-of-type > .frame::before,
.band:last-of-type > .frame::after {
  content: "";
  position: absolute;
  bottom: -5px;
  width: 7px;
  height: 7px;
  box-sizing: border-box;
  border: 1px solid var(--line-2);
  background-color: var(--panel);
}
.band:last-of-type > .frame::before {
  left: -4px;
}
.band:last-of-type > .frame::after {
  right: -4px;
}
@media all and (max-width: 1048px) {
  .band:last-of-type > .frame::before {
    left: 0;
  }
  .band:last-of-type > .frame::after {
    right: 0;
  }
}
.frame.dotted {
  background-image: radial-gradient(var(--dot) 1px, transparent 1.3px);
  background-size: 12px 12px;
}
/* dots live only in the spacer strips between sections and in dotted frames, not down the sides of the page */
.spacer {
  background-image: radial-gradient(var(--dot) 1px, transparent 1.3px);
  background-size: 12px 12px;
}
.spacer .frame {
  height: 48px;
}
.fig {
  position: absolute;
  top: 12px;
  left: 14px;
  color: var(--faint);
}

/* ---------- boxes with corner handles (the corners are added by the script at the bottom) ---------- */

.box {
  position: relative;
  border: 1px solid transparent;
  border-image: var(--dash-img) 1 repeat;
}
.corner {
  position: absolute;
  width: 9px;
  height: 9px;
  box-sizing: border-box;
  border: 1px solid var(--line-2);
  background-color: var(--panel);
  pointer-events: none;
}
.corner.tl {
  top: -5px;
  left: -5px;
}
.corner.tr {
  top: -5px;
  right: -5px;
}
.corner.bl {
  bottom: -5px;
  left: -5px;
}
.corner.br {
  bottom: -5px;
  right: -5px;
}

/* ---------- hero ---------- */

.hero {
  display: grid;
  grid-template-columns: 1.5fr 0.5fr;
}
.hero-text {
  min-width: 0;
  padding: 64px 40px 48px;
}
.hero h1 {
  font-size: clamp(32px, 4.4vw, 52px);
  font-weight: 500;
  line-height: 1.12;
  letter-spacing: -0.025em;
}
.hero h1 span {
  display: block;
}
.hero h1 b {
  font-weight: 600;
  transition: color 200ms;
}
.c-blue {
  color: var(--accent);
}
.c-pink {
  color: var(--pink);
}
.c-grey {
  color: var(--grey);
}
.c-purple {
  color: var(--purple);
}
.c-green {
  color: var(--green);
}
.hero-sub {
  margin-top: 28px;
  max-width: 420px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.7;
}
.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 28px;
}
.hero-figure {
  position: relative;
  min-width: 0; /* the column is sized by the grid, not by what is inside it */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 56px 24px 48px;
  border-left: 1px solid var(--line);
}
.portrait {
  position: relative;
  box-sizing: border-box;
  flex: none;
  width: min(100%, 232px);
  padding: 10px;
  background-color: var(--panel);
}
.portrait img {
  display: block;
  box-sizing: border-box;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border: 1px solid var(--line-2);
  filter: grayscale(0.15);
}
/* the photo comes from html/portrait.html; hold its square until it arrives so nothing jumps */
#portrait-body:empty {
  box-sizing: border-box;
  aspect-ratio: 1 / 1;
  border: 1px solid var(--line-2);
  background-color: var(--hover);
}
.portrait .caption {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
  color: var(--faint);
}
.anno {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  white-space: nowrap;
  font-size: 10px;
}
.anno::before {
  content: "";
  width: 24px;
  border-top: 1px solid var(--line-2);
}
.anno.right {
  top: -26px;
  right: 0;
}
.anno.left {
  bottom: -26px;
  left: 0;
}

/* ---------- me page ---------- */

.hero-kicker {
  display: block;
  margin-bottom: 18px;
  color: var(--faint);
}
.hero h1.name {
  font-size: clamp(30px, 4vw, 46px);
}
.hero-bio {
  max-width: 480px;
  margin-top: 22px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.7;
}
.row.compact {
  align-items: center;
  padding-top: 16px;
  padding-bottom: 16px;
}
/* A row or box that has a link is one big link. The title link is stretched over the whole
   box, so other links inside the text (like p0ndja) still work on their own. */
.linked {
  cursor: pointer;
}
.row.linked {
  padding-right: 64px;
}
.cover {
  color: inherit;
}
.cover::after {
  content: "";
  position: absolute;
  inset: 0;
}
.cover:focus-visible {
  outline: none;
}
.cover:focus-visible::after {
  outline: 1px solid var(--accent);
  outline-offset: -1px;
}
.row p a,
.project p a,
.cells a {
  position: relative;
  z-index: 1;
  color: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-decoration-color: var(--faint);
  text-underline-offset: 3px;
  transition: all 200ms;
}
.row p a:hover,
.project p a:hover,
.cells a:hover {
  color: var(--accent);
  text-decoration-color: var(--accent);
}
.go-icon {
  position: absolute;
  right: 28px;
  top: 28px;
  color: var(--faint);
  font-size: 14px;
  pointer-events: none;
  transition: all 200ms;
}
.row.compact .go-icon {
  top: 50%;
  margin-top: -7px;
}
.project .go-icon {
  top: auto;
  right: 20px;
  bottom: 20px;
}
.linked:hover {
  background-color: var(--hover);
}
.linked:hover .go-icon {
  color: var(--accent);
}
.linked:hover .go {
  translate: 3px 0;
}
.linked:hover .go-ext {
  translate: 2px -2px;
}
/* index pages: the icon in the corner is the only link */
.go-link {
  position: absolute;
  top: 18px;
  right: 18px;
  padding: 10px;
  color: var(--faint);
  font-size: 14px;
  line-height: 1;
  transition: color 200ms;
}
.go-link i {
  display: block;
  transition: translate 200ms;
}
.go-link:hover {
  color: var(--accent);
}
.go-link:hover i {
  translate: 2px -2px;
}
.project .go-link {
  top: auto;
  bottom: 10px;
  right: 10px;
}
.row.has-go {
  padding-right: 64px;
}
.project.has-go p {
  padding-right: 28px;
}
.row.compact:hover {
  background-color: var(--hover);
}
.row.compact .when {
  padding-top: 2px;
}
.row.compact h3 {
  font-size: 16px;
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 16px;
  border: 1px solid var(--line-2);
  color: var(--txt);
  background-color: transparent;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 200ms;
}
.btn:hover {
  background-color: var(--hover);
  border-color: var(--txt);
}
.btn.primary {
  color: var(--accent-ink);
  background-color: var(--accent);
  border-color: var(--accent);
}
.btn.primary:hover {
  opacity: 0.85;
}

/* ---------- social links: one cell each ---------- */

.links {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
}
.links a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 18px 20px;
  border-left: 1px solid var(--line);
  font-size: 14px;
  transition: background-color 200ms;
}
.links a:first-child {
  border-left: 0;
}
.links a:hover {
  background-color: var(--hover);
}
.links i {
  margin-right: 8px;
  color: var(--muted);
}
.links .arrow i {
  margin: 0;
  color: inherit;
}
.links .arrow {
  margin: 0;
  color: var(--faint);
  font-size: 12px;
  transition: all 200ms;
}
.links a:hover .arrow {
  color: var(--accent);
  transform: translate(2px, -2px);
}

/* ---------- section titles ---------- */

.head {
  display: flex;
  align-items: baseline;
  gap: 14px;
  padding: 22px 28px;
}
.head h2 {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.head .mono {
  color: var(--faint);
}
.head .count {
  margin-left: auto;
}

/* ---------- key / value cells (contact, education) ---------- */

.cells {
  display: grid;
  grid-template-columns: repeat(var(--cols, 3), 1fr);
  border-top: 1px solid transparent;
  border-image: var(--dash-img) 1 repeat;
}
.cells > div {
  padding: 22px 28px 26px;
  border-left: 1px solid transparent;
  border-image: var(--dash-img) 1 repeat;
}
.cells > div:first-child {
  border-left: 0;
}
.cells .k {
  display: block;
  margin-bottom: 10px;
  color: var(--faint);
}
.cells .v {
  font-size: 16px;
  font-weight: 500;
  line-height: 1.5;
}
.cells .sub {
  margin-top: 6px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}
.mail + .mail {
  margin-top: 10px;
}
.tagline {
  display: block;
  margin-top: 2px;
  color: var(--faint);
  font-size: 10px;
}

/* ---------- rows (experiences, contributions) ---------- */

.rows {
  border-top: 1px solid transparent;
  border-image: var(--dash-img) 1 repeat;
}
.row {
  position: relative;
  display: grid;
  grid-template-columns: 210px 1fr;
  gap: 24px;
  padding: 22px 28px;
  border-top: 1px solid transparent;
  border-image: var(--dash-img) 1 repeat;
}
.row:first-child {
  border-top: 0;
}
.row .when {
  padding-top: 4px;
  color: var(--faint);
  line-height: 1.6;
}
.row h3 {
  font-size: 17px;
  font-weight: 600;
  line-height: 1.4;
}
.row p {
  margin-top: 8px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.65;
}

/* ---------- project boxes ---------- */

.projects {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  padding: 28px;
  border-top: 1px solid transparent;
  border-image: var(--dash-img) 1 repeat;
}
.project {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 20px;
}
.project header {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--faint);
}
.project h3 {
  font-size: 17px;
  font-weight: 600;
  line-height: 1.4;
}
.project.linked p {
  padding-right: 28px;
}
.project p {
  color: var(--muted);
  font-size: 14.5px;
  line-height: 1.65;
}

/* ---------- links inside the About text ---------- */

#bio a {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-decoration-color: var(--faint);
  text-underline-offset: 4px;
  transition: all 200ms;
}
#bio a:hover {
  color: var(--accent);
  text-decoration-color: var(--accent);
}

/* ---------- resume ---------- */

.resume-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  padding: 28px 28px 8px;
}
.resume-box {
  max-width: 640px;
  margin: 28px auto 0;
  padding: 12px;
}
/* a margin here would collapse through the frame; padding is what extends it */
#resume .frame {
  padding-bottom: 44px;
}
.resume-box img {
  display: block;
  width: 100%;
  border: 1px solid var(--line-2);
}

/* ---------- footer ---------- */

footer {
  margin-top: 0;
}

/* ---------- fixed buttons from basic.css: square, see-through with a blur ---------- */

.ttt,
.swmode,
.lang-th {
  border-radius: 0;
  border: 1px solid var(--line-2);
  color: var(--accent);
  background-color: rgba(255, 255, 255, 0.04);
  background-image: none;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}
.light-theme .ttt,
.light-theme .swmode,
.light-theme .lang-th {
  background-color: rgba(255, 255, 255, 0.3);
  box-shadow: 0 4px 14px rgba(40, 40, 30, 0.16);
}
.ttt:hover,
.swmode:hover,
.lang-th:hover,
.ttt:hover.fa-solid,
.swmode:hover.fa-solid {
  color: var(--txt);
  border-color: var(--txt);
  background-color: rgba(255, 255, 255, 0.08);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  text-shadow: none;
}
.light-theme .ttt:hover,
.light-theme .swmode:hover,
.light-theme .lang-th:hover {
  background-color: rgba(255, 255, 255, 0.5);
  box-shadow: 0 2px 8px rgba(40, 40, 30, 0.14);
}
.light-theme .swmode.fa-solid {
  rotate: 180deg;
}

/* ---------- sub pages: one project per band, text on the side ---------- */

.page-head {
  padding: 56px 40px 40px;
}
.page-head .hero-bio {
  margin-top: 14px;
}
.proj {
  display: grid;
  grid-template-columns: 270px 1fr;
}
.proj-side {
  position: sticky;
  top: 0;
  align-self: start;
  padding: 32px 28px;
}
.proj-side .mono {
  color: var(--faint);
}
.proj-side h2 {
  margin-top: 10px;
  font-size: 19px;
  font-weight: 600;
  line-height: 1.4;
}
.proj-side .when {
  display: block;
  margin-top: 12px;
}
.proj-main {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
  padding: 32px 36px;
  border-left: 1px solid transparent;
  border-image: var(--dash-img) 1 repeat;
}
.proj-main p {
  color: var(--muted);
  font-size: 15.5px;
  line-height: 1.75;
}
.proj-main p a {
  color: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-decoration-color: var(--faint);
  text-underline-offset: 3px;
  transition: all 200ms;
}
.proj-main p a:hover {
  color: var(--accent);
  text-decoration-color: var(--accent);
}
.proj-main p a i {
  margin-left: 4px;
  font-size: 12px;
}
.media {
  padding: 10px;
}
.media .ratio {
  position: relative;
  padding-bottom: 56.25%;
}
.media iframe {
  display: block;
  border: 0;
}
.media .ratio iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.media iframe.flip {
  width: 100%;
  height: 560px;
}
/* Photos keep the proportions and the relative sizes of the old page. The old sizes are read
   against a 900px row: a "large" photo (900) fills the whole row, a "medium" (600) takes two
   thirds, a "small-sq" (150) a sixth, and so on. Everything scales down with the column. */
.gallery {
  container-type: inline-size;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.shot {
  --w: 300;
  --r: 2 / 1;
  box-sizing: border-box;
  flex: 0 1 auto;
  width: calc(var(--w) * 1px);
  width: min(calc(var(--w) * 1px), calc(var(--w) / 900 * 100cqw));
  padding: 0;
}
.shot img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: var(--r);
  object-fit: cover;
  object-position: center;
  cursor: zoom-in;
}
.s-small {
  --w: 300;
  --r: 2 / 1;
}
.s-small-sq {
  --w: 150;
  --r: 1 / 1;
}
.s-medium {
  --w: 600;
  --r: 2 / 1;
}
.s-medium-sq {
  --w: 300;
  --r: 1 / 1;
}
.s-medium-t {
  --w: 225;
  --r: 1 / 2;
}
.s-large {
  --w: 900;
  --r: 2 / 1;
}
.s-large-sq {
  --w: 450;
  --r: 1 / 1;
}
.s-xlarge {
  width: 100%;
  --r: auto;
}

/* Facebook and TikTok posts */
.embed {
  display: flex;
  justify-content: center;
  padding: 10px;
}
.embed > div,
.embed > blockquote {
  max-width: 100%;
  overflow-x: auto;
}
.embed .fb-post {
  display: flex;
  justify-content: center;
}
.embed .tiktok-embed {
  margin: 0 !important;
  border-radius: 8px;
}

/* click a photo: full-size viewer */
.lightbox {
  width: 100vw;
  height: 100vh;
  max-width: none;
  max-height: none;
  padding: 0;
  border: 0;
  color: var(--txt);
  background: transparent;
}
.lightbox[open] {
  display: flex;
  align-items: center;
  justify-content: center;
}
.lightbox::backdrop {
  background: rgba(0, 0, 0, 0.9);
}
.lightbox img {
  max-width: min(92vw, 1500px);
  max-height: 86vh;
  border: 1px solid var(--line-2);
  background-color: var(--panel);
}
.lb-btn {
  position: fixed;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line-2);
  color: var(--txt);
  background-color: var(--panel);
  font-size: 16px;
  cursor: pointer;
  transition: all 200ms;
}
.lb-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}
.lb-close {
  top: 20px;
  right: 20px;
}
.lb-prev {
  top: 50%;
  left: 20px;
  margin-top: -22px;
}
.lb-next {
  top: 50%;
  right: 20px;
  margin-top: -22px;
}
.lightbox.single .lb-prev,
.lightbox.single .lb-next {
  display: none;
}
.lb-count {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  color: #d8d8d8;
}

/* ---------- small screens ---------- */

@media all and (max-width: 860px) {
  .hero {
    grid-template-columns: 1fr;
  }
  .hero-figure {
    border-left: 0;
    border-top: 1px solid var(--line);
  }
  .anno {
    display: none;
  }
  .links {
    grid-template-columns: repeat(3, 1fr);
  }
  .links a:nth-child(4) {
    border-left: 0;
  }
  .links a:nth-child(n + 4) {
    border-top: 1px solid var(--line);
  }
  .cells {
    --cols: 1 !important;
  }
  .cells > div {
    border-left: 0;
    border-top: 1px solid transparent;
    border-image: var(--dash-img) 1 repeat;
  }
  .cells > div:first-child {
    border-top: 0;
  }
  .row {
    grid-template-columns: 1fr;
    gap: 6px;
  }
  .projects {
    grid-template-columns: 1fr;
  }
}
@media all and (max-width: 520px) {
  .hero-text {
    padding: 44px 22px 36px;
  }
  .hero-figure {
    padding: 40px 22px;
  }
  .head,
  .row,
  .cells > div {
    padding-left: 20px;
    padding-right: 20px;
  }
  .projects {
    padding: 20px;
  }
  .links {
    grid-template-columns: repeat(2, 1fr);
  }
  .links a:nth-child(n) {
    border-left: 1px solid var(--line);
    border-top: 1px solid var(--line);
  }
  .links a:nth-child(odd) {
    border-left: 0;
  }
  .links a:nth-child(-n + 2) {
    border-top: 0;
  }
}

@media all and (max-width: 860px) {
  .proj {
    grid-template-columns: 1fr;
  }
  .proj-side {
    position: static;
    padding: 28px 22px 4px;
  }
  .proj-main {
    padding: 18px 22px 30px;
    border-left: 0;
  }
  .page-head {
    padding: 44px 22px 32px;
  }
}

/* phones: photos wrap onto their own lines and keep their own size (as on the old page),
   shrinking only when the screen is narrower than the photo. Tap one to see it larger. */
@media all and (max-width: 560px) {
  .gallery {
    flex-wrap: wrap;
  }
  .shot {
    flex: 0 0 auto;
    width: min(calc(var(--w) * 1px), 100%);
  }
  .s-xlarge {
    width: 100%;
  }
}

/* small screens: each line of photos is centered in the column, like the old page */
@media all and (max-width: 860px) {
  .gallery {
    justify-content: center;
  }
}
