:root {
  --bg: #f8f4ee;
  --bg-soft: #fffaf2;
  --bg-alt: #eee6da;
  --ink: #282521;
  --muted: #6f675e;
  --accent: #b98b73;
  --accent-dark: #805f51;
  --border: rgba(40, 37, 33, 0.12);
  --shadow: 0 18px 50px rgba(70, 52, 38, 0.10);

  --topbar-height: 76px;
  --content-width: 1320px;
}

/* Base */
* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(185, 139, 115, 0.18), transparent 32rem),
    linear-gradient(180deg, #fbf7f0 0%, var(--bg) 40%, #f4eee5 100%);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.65;
}

.text-block p,
.project-row p,
.page-title p,
.hero-section p,
.document-card p {
  text-align: justify;
}

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

a:hover {
  text-decoration: underline;
}

/* Sticky top banner */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  min-height: var(--topbar-height);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1rem;
  padding: 0.8rem 1.2rem;
  background: rgba(248, 244, 238, 0.86);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(16px);
}

.topbar-left {
  justify-self: start;
}

.topbar-center {
  justify-self: center;
  text-align: center;
}

.topbar-right {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.site-name {
  margin: 0;
  font-size: clamp(1.1rem, 2.4vw, 1.65rem);
  letter-spacing: 0.04em;
  font-weight: 700;
}

.tabs {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.tab-button {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 0.45rem 0.68rem;
  border-radius: 999px;
  font: inherit;
  font-size: 0.88rem;
  cursor: pointer;
  transition: 160ms ease;
  white-space: nowrap;
}

.tab-button:hover,
.tab-button.active {
  color: var(--ink);
  background: rgba(185, 139, 115, 0.13);
  border-color: rgba(185, 139, 115, 0.22);
}

.contact-mini {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--muted);
  font-size: 0.82rem;
  white-space: nowrap;
}

.language-selector {
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--ink);
  padding: 0.42rem 0.62rem;
  font: inherit;
  font-size: 0.85rem;
}

/* Layout */
main {
  width: min(var(--content-width), calc(100% - 2rem));
  margin: 2rem auto;
}

.tab-panel {
  display: none;
  animation: fadeIn 180ms ease;
}

.tab-panel.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(0.25rem);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.soft-card,
.page-title,
.project-card,
.document-card {
  background: rgba(255, 250, 242, 0.78);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  border-radius: 28px;
}

.hero-section,
.page-title {
  padding: clamp(1.4rem, 4vw, 3rem);
  margin-bottom: 1.5rem;
}

.hero-section h2,
.page-title h2 {
  margin: 0.15rem 0 0.75rem;
  font-size: clamp(2rem, 5vw, 4rem);
  line-height: 1.05;
  letter-spacing: -0.05em;
}

.eyebrow {
  margin: 0;
  color: var(--accent-dark);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-weight: 700;
}

.text-block h3,
.project-header h3,
.document-card h3 {
  margin-top: 0;
  font-size: clamp(1.3rem, 2vw, 1.8rem);
  line-height: 1.2;
}

/* About layout */
.about-block,
.project-row {
  display: grid;
  grid-template-columns: minmax(300px, 1fr) minmax(300px, 1fr);
  align-items: center;
  gap: clamp(1rem, 4vw, 3rem);
  padding: clamp(1.25rem, 3vw, 2.5rem);
  margin: 0;
  border-radius: 0;
  border-bottom: 1px solid var(--border);
}

.about-block {
  background: rgba(255, 250, 242, 0.55);
  border: 1px solid var(--border);
}

.about-block.text-only {
  grid-template-columns: 1fr;
}

.about-block.text-only .text-block {
  max-width: 900px;
  margin: 0 auto;
}

.reverse {
  grid-template-columns: minmax(300px, 1fr) minmax(300px, 1fr);
}

.alt-bg {
  background: var(--bg-alt);
}

/* Projects */
.project-card {
  margin: 1.5rem 0 2rem;
  overflow: hidden;
}

.project-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: clamp(1.25rem, 3vw, 2.25rem);
  border-bottom: 1px solid var(--border);
}

.project-number {
  display: inline-grid;
  place-items: center;
  min-width: 3rem;
  height: 3rem;
  border-radius: 999px;
  background: rgba(185, 139, 115, 0.16);
  color: var(--accent-dark);
  font-weight: 800;
}

.project-row {
  margin: 0;
  border-radius: 0;
  border-bottom: 1px solid var(--border);
}

.project-row-links {
  grid-template-columns: 1.7fr 0.4fr;
}

.project-row-links-reversed {
  grid-template-columns: 0.4fr 1.7fr;
}

.project-row:last-child {
  border-bottom: 0;
}

.file-links {
  display: grid;
  gap: 0.65rem;
  align-content: center;
}

.file-links h4 {
  margin: 0 0 0.2rem;
  font-size: 1.05rem;
}

.file-links a,
.file-link-placeholder,
.button-link {
  width: fit-content;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.55rem 0.85rem;
  border: 1px solid rgba(185, 139, 115, 0.28);
  background: rgba(255, 250, 242, 0.66);
  color: var(--accent-dark);
  font-weight: 650;
  font-size: 0.9rem;
}

.file-link-placeholder {
  color: var(--muted);
  opacity: 0.68;
}

.button-link {
  background: var(--accent-dark);
  color: white;
}

.button-link.ghost {
  background: transparent;
  color: var(--accent-dark);
}


/* Contact form */
.contact-section {
  display: grid;
  grid-template-columns: minmax(260px, 0.8fr) minmax(300px, 1.2fr);
  gap: clamp(1rem, 4vw, 3rem);
  padding: clamp(1.25rem, 3vw, 2.5rem);
  margin: 1.5rem 0 0;
}

.contact-copy h3 {
  margin: 0.15rem 0 0.75rem;
  font-size: clamp(1.7rem, 3vw, 2.7rem);
  line-height: 1.1;
  letter-spacing: -0.04em;
}

.contact-form {
  display: grid;
  gap: 1rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 1rem;
}

.contact-form label {
  display: grid;
  gap: 0.35rem;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 650;
}

.contact-form input,
.contact-form select,
.contact-form textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(255, 250, 242, 0.86);
  color: var(--ink);
  padding: 0.78rem 0.9rem;
  font: inherit;
  outline: none;
}

.contact-form textarea {
  min-height: 160px;
  resize: vertical;
}

.contact-form input:focus,
.contact-form select:focus,
.contact-form textarea:focus {
  border-color: rgba(185, 139, 115, 0.65);
  box-shadow: 0 0 0 4px rgba(185, 139, 115, 0.12);
}

.contact-submit {
  border: 0;
  cursor: pointer;
  justify-self: start;
}

.contact-submit:disabled {
  cursor: wait;
  opacity: 0.65;
}

.contact-status {
  min-height: 1.4rem;
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.contact-status.success {
  color: #376b42;
}

.contact-status.error {
  color: #9b3d32;
}

.hidden-field {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
}

/* Documents */
.document-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 1rem;
}

.document-card {
  padding: 1.3rem;
}

.document-actions {
  display: flex;
  gap: 0.55rem;
  flex-wrap: wrap;
  margin: 1rem 0;
}

.document-card iframe {
  width: 100%;
  height: 520px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: white;
}

.mobile-pdf-fallback {
  display: none;
  margin: 0.75rem 0 0;
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(185, 139, 115, 0.10);
  color: var(--muted);
  font-size: 0.92rem;
}

.mobile-pdf-preview-fallback .document-card iframe {
  display: none;
}

.mobile-pdf-preview-fallback .mobile-pdf-fallback {
  display: block;
}

/* Images: change these independently */
.media-img {
  width: var(--img-width, 100%);
  max-width: 100%;
  height: var(--img-height, auto);
  object-fit: contain;
  border-radius: var(--img-radius, 24px);
  border: 1px solid var(--border);
  box-shadow: 0 14px 38px rgba(70, 52, 38, 0.10);
  justify-self: center;
}

.img-small {
  --img-width: 260px;
}

.img-medium {
  --img-width: 380px;
}

.img-large {
  --img-width: 680px;
}

/* Individual project image controls */
.project-img-1  { --img-width: 520px; }
.project-img-2  { --img-width: 520px; }
.project-img-3  { --img-width: 880px; }

.project-img-4  { --img-width: 550px; }
.project-img-5  { --img-width: 400px; }
.project-img-6  { --img-width: 820px; }

.project-img-7  { --img-width: 420px; }
.project-img-8  { --img-width: 360px; }
.project-img-9  { --img-width: 700px; }

.project-img-10 { --img-width: 540px; }
.project-img-11 { --img-width: 540px; }
.project-img-12 { --img-width: 720px; }

.project-img-13 { --img-width: 460px; }
.project-img-14 { --img-width: 460px; }
.project-img-15 { --img-width: 800px; }

.project-img-16 { --img-width: 400px; }
.project-img-17 { --img-width: 340px; }
.project-img-18 { --img-width: 620px; }



/* Web Applications */
.webapp-card {
  overflow: hidden;
}

.webapp-layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(320px, 1.1fr);
  gap: clamp(1rem, 4vw, 3rem);
  padding: clamp(1.25rem, 3vw, 2.5rem);
  align-items: start;
}

.webapp-controls {
  display: grid;
  gap: 1rem;
}

.webapp-field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(150px, 1fr));
  gap: 1rem;
}

.webapp-controls label {
  display: grid;
  gap: 0.35rem;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 650;
}

.webapp-controls input:not([type="checkbox"]),
.webapp-controls select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(255, 250, 242, 0.86);
  color: var(--ink);
  padding: 0.78rem 0.9rem;
  font: inherit;
  outline: none;
}

.webapp-controls input:not([type="checkbox"]):focus,
.webapp-controls select:focus {
  border-color: rgba(185, 139, 115, 0.65);
  box-shadow: 0 0 0 4px rgba(185, 139, 115, 0.12);
}

.webapp-controls input:disabled,
.webapp-controls select:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.webapp-toggle {
  align-content: start;
}

.webapp-toggle input[type="checkbox"] {
  width: 1.15rem;
  height: 1.15rem;
  accent-color: var(--accent);
  cursor: pointer;
}

.webapp-expression-label {
  grid-column: 1 / -1;
}

.webapp-help,
.webapp-status {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.webapp-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.webapp-actions button {
  border: 1px solid rgba(185, 139, 115, 0.28);
  cursor: pointer;
}

.webapp-preview {
  display: grid;
  justify-items: center;
  gap: 0.85rem;
  width: 100%;
}

#functionRasterizerCanvas {
  width: min(100%, 560px);
  height: auto;
  max-width: 100%;
  border-radius: 24px;
  border: 1px solid var(--border);
  background: #090807;
  box-shadow: 0 14px 38px rgba(70, 52, 38, 0.10);
  image-rendering: pixelated;
}

.webapp-status.error {
  color: #9b3d32;
}

.plate-trainer-card {
  margin-top: 1.5rem;
}

.plate-trainer-app {
  display: grid;
  grid-template-columns: minmax(220px, 0.7fr) minmax(320px, 1.3fr);
  gap: clamp(1rem, 4vw, 3rem);
  padding: clamp(1.25rem, 3vw, 2.5rem);
  align-items: start;
}

.plate-trainer-side {
  display: grid;
  gap: 1rem;
  align-content: start;
}

.plate-mode-switch {
  display: grid;
  gap: 0.45rem;
  padding: 0;
  margin: 0;
  border: 0;
}

.plate-mode-switch label {
  position: relative;
  cursor: pointer;
}

.plate-mode-switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.plate-mode-switch span {
  min-height: 2.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 250, 242, 0.64);
  color: var(--muted);
  font-weight: 750;
  transition: 160ms ease;
}

.plate-mode-switch input:focus-visible + span {
  outline: 3px solid rgba(185, 139, 115, 0.28);
  outline-offset: 2px;
}

.plate-mode-switch input:checked + span {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
  color: #fff;
}

.plate-trainer-scoreboard {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.6rem;
}

.plate-trainer-scoreboard > span {
  min-height: 4.2rem;
  display: grid;
  align-content: center;
  gap: 0.1rem;
  padding: 0.65rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255, 250, 242, 0.56);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  text-align: center;
}

.plate-trainer-scoreboard strong {
  color: var(--ink);
  font-size: 1.15rem;
  line-height: 1;
}

.plate-trainer-question {
  display: grid;
  gap: 1rem;
}

.plate-question-kicker {
  margin: 0;
  color: var(--accent-dark);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-weight: 750;
}

.plate-trainer-prompt {
  min-height: clamp(5.5rem, 16vw, 8.6rem);
  display: flex;
  align-items: center;
  color: var(--ink);
  font-size: clamp(3.4rem, 10vw, 7.2rem);
  font-weight: 850;
  line-height: 0.95;
  letter-spacing: 0;
  word-break: break-word;
}

.plate-answer-label {
  display: grid;
  gap: 0.35rem;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 650;
}

.plate-answer-label input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(255, 250, 242, 0.86);
  color: var(--ink);
  padding: 0.82rem 0.9rem;
  font: inherit;
  outline: none;
}

.plate-answer-label input:focus {
  border-color: rgba(185, 139, 115, 0.65);
  box-shadow: 0 0 0 4px rgba(185, 139, 115, 0.12);
}

.plate-trainer-actions button:disabled {
  opacity: 0.62;
  cursor: wait;
}

.plate-trainer-feedback {
  min-height: 3.4rem;
  margin: 0;
  color: var(--muted);
  font-size: 0.98rem;
  font-weight: 650;
}

.plate-trainer-feedback.correct {
  color: #28744a;
}

.plate-trainer-feedback.incorrect {
  color: #9b3d32;
}

.plate-trainer-feedback.skipped {
  color: #7c5a12;
}

/* Footer */
footer {
  width: min(var(--content-width), calc(100% - 2rem));
  margin: 2rem auto;
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
}

/* Mobile */
@media (max-width: 860px) {
  .topbar {
    grid-template-columns: 1fr;
    justify-items: center;
    gap: 0.6rem;
  }

  .topbar-left,
  .topbar-center,
  .topbar-right {
    justify-self: center;
  }

  .contact-mini {
    white-space: normal;
    justify-content: center;
  }

  main {
    margin-top: 1rem;
  }

  .about-block,
  .project-row,
  .reverse {
    grid-template-columns: 1fr;
  }

  .document-grid {
    grid-template-columns: 1fr;
  }

  .contact-section,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .document-card iframe {
    height: 420px;
  }

  .tabs {
    flex-wrap: wrap;
    justify-content: center;
  }

  .webapp-layout,
  .webapp-field-grid,
  .plate-trainer-app {
    grid-template-columns: 1fr;
  }

  .plate-mode-switch {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .plate-mode-switch,
  .plate-trainer-scoreboard {
    grid-template-columns: 1fr;
  }

  .plate-trainer-scoreboard > span {
    min-height: 3.3rem;
  }
}
