@import url('https://fonts.googleapis.com/css2?family=Lora:ital,wght@0,400..700;1,400..700&display=swap');

:root {
  --max-w: 960px;
  --space: 1rem;
  --space-lg: 1.75rem;
  --bg: #f8fbf8;
  --fg: #0b1220;
  --muted: #5a6472;
  --brand: #0b84ff;
  --brand-ink: #0a66c2;
  --h1: 2.75rem;
  --h2: 2rem;
  --lead: 1.2rem;
  --hero-min: 35dvh;
  --header-bg: #ffffff;

  /* NEW: Project card CSS variables */
  --project-card-bg: #fff;
  --project-card-border: 1px solid rgba(0,0,0,.1);
  --project-card-radius: 0.6rem;
  --project-card-padding: clamp(.9rem, .6rem + 1vw, 1.25rem);
  --project-card-gap: clamp(.9rem, .6rem + 1vw, 1.25rem);
  --project-card-shadow: none;
  --project-card-heading-color: #0b1220;
  --project-card-text-color: #0b1220;
  --project-card-muted-color: #5a6472;
  --project-card-link-color: #0a66c2;
  --project-media-bg: #f4f6f8;
  --project-media-radius: 0.45rem;
  --project-media-flex: 0 0 min(22rem, 38dvw);
  --project-tag-border: 1px solid rgba(0,0,0,.18);
  --project-tag-radius: 0.35rem;
  --project-tag-padding: .25em .6em;
  --project-tag-size: .85rem;
}

html { font-size: 105%; }

body.site {
  margin: 0;
  background-color: var(--bg, #f8fbf8);
  color: var(--fg, #111);
  font-family: "Lora", Georgia, "Times New Roman", serif;
  line-height: 1.65;
  font-optical-sizing: auto;
}

/* Dark theme */
body[data-theme="dark"] {
  --bg: #0b1220;
  --fg: #f8fbf8;
  --muted: #9ca3af;
  --brand: #3b82f6;
  --brand-ink: #2563eb;
  --header-bg: #1f2937;

  /* UPDATED: Dark theme project card variables */
  --project-card-bg: #1f2937;
  --project-card-border: 1px solid rgba(255,255,255,.1);
  --project-card-heading-color: #f8fbf8;
  --project-card-text-color: #f8fbf8;
  --project-card-muted-color: #9ca3af;
  --project-card-link-color: #3b82f6;
  --project-media-bg: #374151;
  --project-tag-border: 1px solid rgba(255,255,255,.18);
}

/* Layout wrappers */
.site-header,
.site-main,
.site-footer {
  max-width: var(--max-w, 960px); /* var fallback */
  margin-inline: auto;
  padding-inline: var(--space, 1rem); /* var fallback */
}

.site-header {
  padding-block: 1.5rem 0.5rem;
  background-color: var(--header-bg, #ffffff);
}

.site-footer {
  padding-block: 0 1.5rem;
  text-align: center;
  color: var(--muted, #666); /* var fallback */
}

@keyframes slide-in-down {
  from {
    opacity: 0;
    transform: translateY(-18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.site-header {
  animation: slide-in-down 600ms ease-out both;
}

.site-nav {
  animation: slide-in-down 600ms ease-out both;
}

/* Headings & nav */
.site-header h1 {
  font-size: var(--h1, 2.5rem); /* var fallback */
  margin: 0 0 0.25rem;
}

.site-nav {
  display: flex; /* Flexbox */
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  font-size: 1.05rem;
}

.site-nav {
    a {
        position: relative;
        color: var(--brand-ink, #0a66c2);
        text-decoration: none;
        transition: color 0.2s ease;
    }
}

.site-nav a::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -2px;
  width: 0%;
  height: 2px;
  background-color: var(--brand, #0b84ff);
  transition: width 0.25s ease;
}

.site-nav a:hover {
  color: #005eff;
}

.site-nav a:hover::after {
  width: 100%;
}

.site-nav a[aria-current="page"] { font-weight: 600; }

/* Theme toggle */
.theme-toggle {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  z-index: 1000;
  padding: 0.75rem;
  background: var(--brand, #0b84ff);
  color: white;
  border: none;
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.1s ease;
  box-shadow: var(--shadow, rgba(0,0,0,.1));
}

.theme-toggle:hover {
  background: var(--brand-ink, #0a66c2);
  transform: scale(1.05);
}

.theme-toggle:active {
  transform: scale(0.95);
}

.theme-toggle[aria-pressed="true"] {
  background: var(--muted, #5a6472);
}

/* Main content grid */
.site-main {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-lg, 1.75rem);
  padding-block: 1rem 2rem;
}

/* Profile photo */
.profile {
  text-align: center;
  margin-block: 1rem;
}

.headshot {
  width: clamp(14rem, 28dvw, 20rem);
  aspect-ratio: 1;
  border-radius: var(--radius-full, 9999px);
  object-fit: cover;
  object-position: center 25%;
  display: block;
  margin: 1rem auto 1.25rem;
  animation: float-in 600ms ease-out both;
  will-change: transform, opacity;
}
.headshot:hover {
  transform: scale(1.03);
  transition: transform .15s ease;
}

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Hero section */
.hero {
  min-block-size: var(--hero-min, 35vh);
  display: grid;
  place-items: center;
  text-align: center;
  padding-block: 0;
}

.hero-title {
  font-size: var(--h2, 2rem);
  margin-block: 0 0.5rem;
  animation: fade-up 600ms ease-out both;
}

.lead { font-size: var(--lead, 1.1rem); }

.intro-text {
  max-width: 65ch;
  margin-inline: auto;
  margin-block: 0 0.75rem;
}

.progress-row { margin: 0; }

/* Animate hero text on load */
.hero p,
.hero progress {
  opacity: 0;
  animation: fade-up 600ms ease-out both;
}

/* Respect reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
  .hero p,
  .hero progress {
    animation: none;
    opacity: 1;
    transform: none;
  }
}

/* Media query */
@media (max-width: 22rem) {
  .site-header { padding-block: 1rem 0.25rem; }
  .headshot { width: 12rem; margin: 0.75rem auto 1rem; }
}

/* Native CSS Nesting (supported): scope to header nav link tweaks */
.site-header {
  nav {
    a { padding: 0.25em 0.15em; border-radius: 0.35em; }
  }
}

/* ABOUT — minimal headers */

.section-title{
  font-size: clamp(1.5rem, 1.1rem + 1.2vw, var(--h2, 2rem));
  font-weight: 600;
  margin: 0;
}

.rule {
  border: 0;
  height: 1px;
  background: rgba(0,0,0,.12);
  margin: .6rem 0 1rem;
}

ul.tight {
  margin: 0 0 1rem;
  padding-left: 1.1rem;
}
ul.tight li { margin: .35rem 0; }

.about-section {
  opacity: 0;
  animation: fade-up 600ms ease-out both;
}
.about-section:nth-of-type(1) { animation-delay: .05s; }
.about-section:nth-of-type(2) { animation-delay: .12s; }
.about-section:nth-of-type(3) { animation-delay: .19s; }
.about-section:nth-of-type(4) { animation-delay: .26s; }

@media (prefers-reduced-motion: reduce) {
  .about-section { animation: none; opacity: 1; transform: none; }
}

/* CONTACT — flex layout */
.contact-wrap {
  display: flex;                    /* Flexbox requirement */
  gap: var(--space-lg, 1.75rem);
  align-items: flex-start;
  flex-wrap: wrap;
  min-block-size: 50dvh;            /* dynamic viewport unit */
  animation: fade-up 700ms ease-out both;
}

.contact-aside {
  flex: 1 1 16rem;                  /* relative sizing */
  max-width: 22rem;
}

.contact-main {
  flex: 2 1 26rem;                  /* grow more than aside */
  min-inline-size: min(90dvw, 36rem);
}

.subhead {
  font-size: 1.05rem;
  margin: 0 0 .25rem;
  color: var(--muted, #5a6472);
  font-weight: 600;
}

/* Link list */
.contact-links {
  list-style: none;
  padding-left: 0;
  margin: .5rem 0 0;
}
.contact-links li { margin: .35rem 0; }
.contact-links a {
  color: var(--brand-ink, #0a66c2);
  text-decoration: underline;
  transition: color .2s ease;       /* transition requirement */
}
.contact-links a:hover { color: #005eff; }

/* Form (native nesting used below) */
.contact-form {
  display: grid;
  gap: 1rem;
  animation: fade-up 700ms ease-out both;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.contact-form {
  label { font-weight: 600; font-size: .95rem; }
  input, textarea {
    font: inherit;
    padding: .7rem;
    border: 1px solid rgba(0,0,0,.2);
    border-radius: .4rem;
    width: 100%;
    transition: border-color .2s ease, transform .12s ease; /* transitions */
  }
  input:focus, textarea:focus {
    outline: 2px solid var(--brand, #0b84ff);
    outline-offset: 2px;
    border-color: var(--brand, #0b84ff);
    transform: translateY(-1px);    /* transform requirement */
  }
  button {
    width: fit-content;
    padding: .65rem 1.2rem;
    border: none;
    border-radius: .4rem;
    background: var(--brand, #0b84ff);
    color: #fff;
    font-weight: 700;
    cursor: pointer;
    transition: transform .12s ease, background-color .2s ease;
  }
  button:hover { transform: translateY(-1px); background-color: #005eff; }
}

.form-field label[for]:has(+ input[required])::after,
.form-field label[for]:has(+ textarea[required])::after {
  content: " *";
  color: #c33;
  font-weight: 700;
}

.contact-form input:required,
.contact-form textarea:required {
  border-left: 3px solid #0b84ff;
}

.contact-form input:optional,
.contact-form textarea:optional {
  border-left: 3px solid #ccc;
}

.contact-form input:invalid:not(:placeholder-shown),
.contact-form textarea:invalid:not(:placeholder-shown) {
  border-color: #dc3545;
  background-color: #fff5f5;
}

.contact-form input:invalid:focus:not(:placeholder-shown),
.contact-form textarea:invalid:focus:not(:placeholder-shown) {
  outline-color: #dc3545;
  border-color: #dc3545;
}

.contact-form input:valid:not(:placeholder-shown),
.contact-form textarea:valid:not(:placeholder-shown) {
  border-color: #28a745;
  background-color: #f8fff8;
}

.contact-form input:user-invalid,
.contact-form textarea:user-invalid {
  border-color: #dc3545;
  background-color: #fff5f5;
}

.flash-error {
  animation: flash-error 0.2s ease-in-out;
}

@keyframes flash-error {
  from {
    background-color: #ffe6e6;
    border-color: #ff6b6b;
  }
  to {
    background-color: inherit;
    border-color: inherit;
  }
}

.near-limit {
  border-color: #d97706 !important;
  background-color: #fff7ed;
}

.contact-form input:user-valid,
.contact-form textarea:user-valid {
  border-color: #28a745;
  background-color: #f8fff8;
}

.message {
  display: block;
  padding: 0.75rem;
  border-radius: 0.4rem;
  font-size: 0.95rem;
  min-height: 2.5rem;
}

.message:empty {
  opacity: 0;
  padding: 0;
  min-height: 0;
  border: none;
}

.message.error {
  background-color: #fee;
  border: 1px solid #fcc;
  color: #c33;
}

.message.info {
  background-color: #e8f4fd;
  border: 1px solid #b3d9f2;
  color: #0b1220;
}

/* Media query: stack vertically on narrow viewports */
@media (max-width: 48rem) {
  .contact-wrap { flex-direction: column; }
  .contact-main { min-inline-size: 100%; }
}

/* Baseline 2024 feature: @scope — limit accent/focus styling to the form only */
@scope (.contact-form) {
  input:focus,
  textarea:focus {
    box-shadow: 0 0 0 .15rem color-mix(in srgb, var(--brand, #0b84ff), transparent 80%); /* EC color-mix */
  }
}

/* Extra credit selector: style form container when any field is focused */
.contact-form:has(:focus-visible) {
  outline: none;                            /* turn off container outline */
}

/* Reduced motion: honor user preference */
@media (prefers-reduced-motion: reduce) {
  .contact-wrap, .contact-form { animation: none; }
}

.contact-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.icon {
  width: 1.2rem;
  height: auto;
  object-fit: contain;
  flex-shrink: 0;
  transform: translateY(0.3rem);
}

/* Projects controls (Load Local / Load Remote buttons) */
.projects-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-block: 1rem;
  align-items: center;
}

.projects-controls button {
  padding: 0.45rem 1rem;
  border-radius: 999px;
  border: 1px solid var(--border-subtle, rgba(0, 0, 0, 0.1));
  background: var(--project-card-bg, #ffffff);
  color: var(--fg, #0b1220);
  font-size: 0.9rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

.projects-controls button:hover {
  background: var(--brand, #0b84ff);
  color: #fff;
  transform: translateY(-1px);
}

.projects-controls button:active {
  transform: translateY(0);
}

/* UPDATED: Projects layout — supports custom <project-card> elements */
.projects-list{
  display: grid;
  gap: clamp(1rem, 1vw + .5rem, 1.5rem);
  padding: 0;
  margin: 0;
  list-style: none;
}

/* NEW: Style for custom element host */
project-card {
  display: block;
}

/* NEW: Styles for <project-card> custom element internals */
project-card .card {
  display: flex;
  align-items: stretch;
  gap: var(--project-card-gap);
  background: var(--project-card-bg);
  border: var(--project-card-border);
  border-radius: var(--project-card-radius);
  padding: var(--project-card-padding);
  box-shadow: var(--project-card-shadow);
  transition: box-shadow 0.2s ease;
}

/* Responsive layout for project cards */
@media (max-width: 56rem) {
  project-card .card {
    flex-direction: column;
  }
}

@media (min-width: 56rem) {
  project-card .card {
    flex-direction: row;
  }
}

/* Media (image) section */
project-card .media {
  flex: var(--project-media-flex);
  margin: 0;
  border-radius: var(--project-media-radius);
  overflow: hidden;
  background: var(--project-media-bg);
  display: grid;
  place-items: center;
}

project-card .media picture {
  width: 100%;
  height: 100%;
  display: block;
}

project-card .media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  aspect-ratio: 16 / 10;
  display: block;
}

/* Content section */
project-card .body {
  flex: 1 1 24rem;
  display: grid;
  gap: .6rem;
  align-content: start;
}

project-card h2 {
  margin: 0;
  font-size: clamp(1.1rem, 1rem + .5vw, 1.45rem);
  color: var(--project-card-heading-color);
  font-family: inherit;
}

project-card .description {
  margin: 0;
  line-height: 1.65;
  color: var(--project-card-text-color);
}

/* Tags */
project-card .tags {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem .5rem;
  padding: 0;
  margin: .1rem 0;
  list-style: none;
}

project-card .tag {
  font-size: var(--project-tag-size);
  padding: var(--project-tag-padding);
  border: var(--project-tag-border);
  border-radius: var(--project-tag-radius);
  color: var(--project-card-muted-color);
}

/* Links */
project-card .links {
  display: flex;
  gap: .6rem;
  margin: .2rem 0 0;
}

project-card .links a {
  text-decoration: none;
  color: var(--project-card-link-color);
  font-weight: 700;
  transition: text-decoration 0.2s ease;
}

project-card .links a:hover {
  text-decoration: underline;
}

/* Hide empty sections */
project-card .tags:empty,
project-card .links:empty {
  display: none;
}

/* Legacy support for non-custom-element cards (if any) */
.project-card{
  display: flex;
  align-items: stretch;
  gap: clamp(.9rem, .6rem + 1vw, 1.25rem);
  background: var(--project-card-bg, #fff);
  border: var(--project-card-border, 1px solid rgba(0,0,0,.1));
  border-radius: var(--project-card-radius, .6rem);
  padding: clamp(.9rem, .6rem + 1vw, 1.25rem);
}

/* mobile: stack */
@media (max-width: 56rem){
  .project-card{ flex-direction: column; }
}

/* desktop: always image left, text right */
@media (min-width: 56rem){
  .project-card{ flex-direction: row; }
}

/* media (image slot) */
.project-media{
  flex: 0 0 min(22rem, 38dvw);
  margin: 0;
  border-radius: .45rem;
  overflow: hidden;
  background: #f4f6f8;
  display: grid;
  place-items: center;
}
.project-media img{
  width: 100%;
  height: 100%;
  object-fit: cover;
  aspect-ratio: 16 / 10;
  display: block;
}

/* text */
.project-body{
  flex: 1 1 24rem;
  display: grid;
  gap: .6rem;
  align-content: start;
}
.project-title{ margin: 0; font-size: clamp(1.1rem, 1rem + .5vw, 1.45rem); }
.project-desc{ margin: 0; line-height: 1.65; }
.project-meta{
  display: flex; flex-wrap: wrap; gap: .4rem .5rem;
  padding: 0; margin: .1rem 0; list-style: none;
}
.tag{
  font-size: .85rem; padding: .25em .6em;
  border: 1px solid rgba(0,0,0,.18); border-radius: .35rem;
  color: #5a6472;
}
.project-links{ display:flex; gap:.6rem; margin: .2rem 0 0; }
.button-ghost{ text-decoration:none; border:1px solid rgba(0,0,0,.18); padding:.5rem .85rem; border-radius:.4rem; color:#0b1220; }
.button-link{ text-decoration:none; color:#0a66c2; font-weight:700; }
.button-link:hover{ text-decoration:underline; }

/* Baseline 2024 feature: @scope — limits styles to .hero subtree only */
@scope (.hero) {
  progress[value] { accent-color: var(--brand, #0b84ff); }
}

/* Keyframes for the headshot animation */
@keyframes float-in {
  from { opacity: 0; transform: translateY(8px) scale(.985); }
  to   { opacity: 1; transform: translateY(0)    scale(1); }
}

/* View Transitions */
::view-transition-old(root) {
  animation: none;
}

::view-transition-new(root) {
  animation: fade-in 0.3s ease-in-out;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* CRUD Page Styles */
.crud-info {
  margin-bottom: 1.5rem;
  line-height: 1.6;
}

.crud-form {
  display: grid;
  gap: 1rem;
  max-width: 36rem;
}

.crud-form .form-field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.crud-form label {
  font-weight: 600;
  font-size: 0.95rem;
}

.crud-form input,
.crud-form textarea {
  font: inherit;
  padding: 0.7rem;
  border: 1px solid rgba(0,0,0,.2);
  border-radius: 0.4rem;
  width: 100%;
  transition: border-color 0.2s ease;
}

.crud-form input:focus,
.crud-form textarea:focus {
  outline: 2px solid var(--brand, #0b84ff);
  outline-offset: 2px;
  border-color: var(--brand, #0b84ff);
}

.crud-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.crud-btn {
  padding: 0.6rem 1.25rem;
  border: none;
  border-radius: 0.4rem;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  transition: transform 0.1s ease, background-color 0.15s ease;
}

.crud-btn:hover {
  transform: translateY(-1px);
}

.crud-btn:active {
  transform: translateY(0);
}

.crud-btn-create {
  background: #22c55e;
  color: #fff;
}

.crud-btn-create:hover {
  background: #16a34a;
}

.crud-btn-update {
  background: var(--brand, #0b84ff);
  color: #fff;
}

.crud-btn-update:hover {
  background: var(--brand-ink, #0a66c2);
}

.crud-btn-delete {
  background: #ef4444;
  color: #fff;
}

.crud-btn-delete:hover {
  background: #dc2626;
}

.crud-status {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  border-radius: 0.4rem;
  font-size: 0.95rem;
  min-height: 1rem;
}

.crud-status:empty {
  display: none;
}

.crud-status-success {
  background: #dcfce7;
  border: 1px solid #86efac;
  color: #166534;
}

.crud-status-error {
  background: #fee2e2;
  border: 1px solid #fca5a5;
  color: #991b1b;
}

.crud-project-list {
  list-style: none;
  padding: 0;
  margin: 1rem 0;
  display: grid;
  gap: 0.5rem;
}

.crud-project-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  padding: 0.75rem 1rem;
  background: var(--project-card-bg, #fff);
  border: var(--project-card-border, 1px solid rgba(0,0,0,.1));
  border-radius: 0.4rem;
}

.crud-project-item code {
  font-size: 0.85rem;
  background: rgba(0,0,0,.05);
  padding: 0.15em 0.4em;
  border-radius: 0.25rem;
  color: var(--muted, #5a6472);
}

.crud-project-tags {
  font-size: 0.8rem;
  color: var(--muted, #5a6472);
}

.crud-empty {
  color: var(--muted, #5a6472);
  font-style: italic;
}