:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --text: #1c1d1f;
  --muted: #5f6368;
  --border: #e2e2de;
  --accent: #1f4e79;
  --accent-soft: #e8eef5;
  --font: "IBM Plex Sans Thai", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121314;
    --surface: #1b1c1e;
    --text: #e8e8e6;
    --muted: #a0a3a8;
    --border: #2e3033;
    --accent: #8db8e3;
    --accent-soft: #1d2a38;
    color-scheme: dark;
  }
}

/* Language switching: hide the language that is not selected */
html[data-lang="th"] [lang="en"],
html[data-lang="en"] [lang="th"] {
  display: none;
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.7;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

.wrap {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 16px;
}

.wrap-wide {
  max-width: 1120px;
}

/* Top bar */
.topbar {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}

.brand {
  color: var(--text);
  font-weight: 600;
  letter-spacing: 0.01em;
}

.brand:hover {
  text-decoration: none;
}

.nav {
  display: flex;
  align-items: center;
  gap: 20px;
}

.nav > a {
  color: var(--muted);
  font-size: 15px;
}

.nav > a:hover,
.nav > a[aria-current="page"] {
  color: var(--accent);
  text-decoration: none;
}

.lang-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}

.lang-toggle:hover {
  border-color: var(--accent);
}

html[data-lang="th"] .lang-opt[data-opt="th"],
html[data-lang="en"] .lang-opt[data-opt="en"] {
  color: var(--accent);
  font-weight: 600;
}

.lang-sep {
  opacity: 0.5;
}

/* Hero */
.hero {
  padding: 72px 0 40px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.02em;
}

h1 {
  margin: 0 0 16px;
  font-size: clamp(2.2rem, 7vw, 3.2rem);
  font-weight: 600;
  line-height: 1.2;
}

.lead {
  max-width: 60ch;
  margin: 0;
  color: var(--muted);
  font-size: 1.1rem;
}

/* Sections */
.block {
  padding: 32px 0;
  border-top: 1px solid var(--border);
}

h2 {
  margin: 0 0 16px;
  font-size: 1.25rem;
  font-weight: 600;
}

h3 {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 500;
}

.block p {
  max-width: 65ch;
  margin: 0 0 12px;
}

/* Skills */
.skills {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.skill-group {
  padding: 16px 20px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.skill-group ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.skill-group li {
  padding: 2px 0;
}

/* Photos page */
.page-head {
  padding: 56px 0 32px;
}

.more {
  margin: 16px 0 0;
}

.wrap-wide > .more {
  padding-bottom: 40px;
}

/* Home page teaser: a strip of small square thumbnails linking to /photos/ */
.teaser {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
  max-width: 560px;
  margin-top: 16px;
}

.teaser img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 4px;
  transition: opacity 0.2s ease;
}

.teaser:hover img {
  opacity: 0.8;
}

@media (max-width: 420px) {
  .teaser {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Gallery: CSS columns keep each photo's own aspect ratio */
.gallery {
  columns: 300px;
  column-gap: 16px;
}

.gallery figure {
  margin: 0 0 24px;
  break-inside: avoid;
}

.gallery .photo {
  display: block;
  overflow: hidden;
  border-radius: 8px;
  background: var(--border);
}

.gallery img {
  display: block;
  width: 100%;
  height: auto;
  transition: transform 0.3s ease;
}

.gallery .photo:hover img {
  transform: scale(1.03);
}

.gallery figcaption {
  margin-top: 8px;
  color: var(--muted);
  font-size: 14px;
}

.lightbox {
  max-width: min(1200px, 96vw);
  max-height: 96vh;
  padding: 0;
  border: 0;
  background: transparent;
  color: #e8e8e6;
  overflow: visible;
}

.lightbox::backdrop {
  background: rgba(0, 0, 0, 0.88);
}

.lightbox img {
  display: block;
  max-width: 100%;
  max-height: calc(96vh - 48px);
  margin: 0 auto;
  border-radius: 4px;
  cursor: zoom-out;
}

.lightbox-caption {
  margin: 8px 0 0;
  text-align: center;
  font-size: 14px;
}

.lightbox form {
  position: absolute;
  top: -44px;
  right: 0;
}

.lightbox-close {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #e8e8e6;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}

.lightbox-close:hover {
  background: rgba(255, 255, 255, 0.12);
}

/* Contact */
.contact {
  margin: 0;
  padding: 0;
  list-style: none;
}

.contact li {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  padding: 8px 0;
}

.contact-label {
  min-width: 80px;
}

@media (max-width: 420px) {
  .nav {
    gap: 12px;
  }
  color: var(--muted);
}

.contact a {
  overflow-wrap: anywhere;
}

/* Footer */
.footer {
  padding-top: 24px;
  padding-bottom: 40px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 14px;
}

.footer p {
  margin: 0;
}

/* 404 page */
.notfound {
  padding-top: 96px;
  padding-bottom: 96px;
}

.notfound .code {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 15px;
  font-weight: 500;
}
