/* ============================================================
   Reusable components
   ============================================================ */

/* ---- Buttons --------------------------------------------- */
.btn {
  --btn-py: 0.75rem;
  --btn-px: 1.375rem;
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5em;
  padding: var(--btn-py) var(--btn-px);
  border-radius: var(--r-md);
  font-size: var(--t-sm);
  font-weight: 500;
  letter-spacing: -0.01em;
  white-space: nowrap;          /* CTA labels never wrap */
  cursor: pointer;
  transition:
    transform var(--dur-fast) var(--ease-out),
    background-color var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out);
  will-change: transform;
}
.btn:active { transform: translateY(1px) scale(0.985); }
.btn i { font-size: 1.05em; transition: transform var(--dur) var(--ease-out); }
.btn:hover i { transform: translateX(3px); }

.btn--sm { --btn-py: 0.5rem; --btn-px: 0.95rem; }
.btn--lg { --btn-py: 0.9375rem; --btn-px: 1.75rem; font-size: var(--t-body); }

.btn--primary {
  background: var(--accent);
  color: var(--accent-ink);     /* 6.7:1 */
  box-shadow: 0 1px 0 rgb(255 255 255 / 0.22) inset;
}
.btn--primary:hover { background: color-mix(in srgb, var(--accent) 88%, var(--text)); }

.btn--ghost {
  color: var(--text);
  border: 1px solid var(--line-strong);
  background: transparent;
}
.btn--ghost:hover { border-color: var(--text-3); background: var(--surface-2); }

/* A panel button stays highlighted while its panel is open, so it
   reads as the active, click-to-close control. */
.btn.is-open.btn--ghost { border-color: var(--accent); color: var(--accent-text); background: var(--accent-soft); }
.btn.is-open.btn--primary { box-shadow: inset 0 0 0 2px rgb(20 16 13 / 0.28); }

.btn--quiet { color: var(--text-2); padding-inline: 0; }
.btn--quiet:hover { color: var(--text); }

.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.55; pointer-events: none; }

/* Inline text link with a drawn underline */
.tlink {
  position: relative;
  color: var(--text);
  display: inline-flex; align-items: center; gap: 0.4em;
  padding-bottom: 2px;
}
.tlink::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 1px;
  background: currentColor; opacity: 0.3;
  transform: scaleX(1); transform-origin: right;
  transition: transform var(--dur) var(--ease-out), opacity var(--dur) var(--ease-out);
}
.tlink:hover::after { opacity: 1; transform-origin: left; }
.tlink i { transition: transform var(--dur) var(--ease-out); }
.tlink:hover i { transform: translate(3px, -3px); }

/* ---- Chips / filters ------------------------------------- */
.chips { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.chip {
  padding: 0.4rem 0.85rem;
  border-radius: var(--r-full);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-2);
  font-size: var(--t-xs);
  transition: color var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out), background-color var(--dur-fast) var(--ease-out);
}
.chip:hover { color: var(--text); border-color: var(--line-strong); }
.chip[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.chip--static { pointer-events: none; }

/* ---- Media ----------------------------------------------- */
.media {
  position: relative;
  overflow: hidden;
  border-radius: var(--r-lg);
  background: var(--surface-2);
  isolation: isolate;
}
.media img {
  width: 100%; height: 100%; object-fit: cover;
  filter: var(--media-filter);
  transform: scale(1.02);
  transition: filter var(--dur-slow) var(--ease-out), transform var(--dur-slow) var(--ease-out);
}
.media--4x5 { aspect-ratio: 4 / 5; }
.media--3x2 { aspect-ratio: 3 / 2; }
.media--1x1 { aspect-ratio: 1 / 1; }
.media--16x9 { aspect-ratio: 16 / 9; }

/* ---- Work card ------------------------------------------- */
.workcard { display: block; }
.workcard .media img { will-change: transform; }
.workcard:hover .media img,
.workcard:focus-visible .media img {
  filter: none;                 /* colour returns on hover: feedback, not decoration */
  transform: scale(1.045);
}
.workcard__meta {
  display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-4);
  margin-top: var(--s-4);
}
.workcard__title { font-size: var(--t-h3); font-weight: 500; letter-spacing: -0.02em; }
.workcard__year { font-family: var(--font-mono); font-size: var(--t-xs); color: var(--text-3); flex-shrink: 0; }
.workcard__summary { color: var(--text-2); font-size: var(--t-sm); margin-top: var(--s-2); max-width: 46ch; }
.workcard__tags { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-top: var(--s-3); }
.workcard__tag {
  font-family: var(--font-mono); font-size: var(--t-micro);
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text-3);
  border: 1px solid var(--line); border-radius: var(--r-full);
  padding: 0.25rem 0.6rem;
}

/* ---- Panel ----------------------------------------------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: clamp(1.5rem, 1rem + 1.6vw, 2.25rem);
}
.panel--sunken { background: var(--surface-2); }
.panel--accent {
  background:
    radial-gradient(120% 140% at 8% 0%, var(--accent-soft), transparent 62%),
    var(--surface);
}

/* ---- Notice ---------------------------------------------- */
.notice {
  display: flex; align-items: flex-start; gap: var(--s-3);
  padding: var(--s-4);
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-md);
  color: var(--text-2);
  font-size: var(--t-sm);
  background: var(--surface);
}
.notice i { color: var(--accent-text); font-size: 1.15rem; flex-shrink: 0; margin-top: 1px; }

/* ---- Forms ----------------------------------------------- */
.field { display: flex; flex-direction: column; gap: var(--s-2); }
.field__label { font-size: var(--t-sm); font-weight: 500; color: var(--text); }
.field__hint  { font-size: var(--t-xs); color: var(--text-2); }
.field__error {
  font-size: var(--t-xs); color: var(--accent-text); font-weight: 500;
  display: flex; align-items: center; gap: 0.4em;
}
.field__error:empty { display: none; }

.input, .textarea, .select {
  width: 100%;
  padding: 0.8125rem 0.9375rem;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  font-size: var(--t-sm);
  transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out), background-color var(--dur-fast) var(--ease-out);
}
.textarea { resize: vertical; min-height: 8rem; line-height: 1.55; }
.input::placeholder, .textarea::placeholder { color: var(--text-3); }  /* placeholder is a hint, never a label */
.input:hover, .textarea:hover, .select:hover { border-color: var(--text-3); }
.input:focus-visible, .textarea:focus-visible, .select:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.field[data-invalid="true"] .input,
.field[data-invalid="true"] .textarea,
.field[data-invalid="true"] .select { border-color: var(--accent-text); }

/* Budget: a currency toggle (euro or dollar) beside a typed amount, so a
   small budget can be entered plainly rather than picked from brackets. */
.budget { display: flex; gap: var(--s-2); align-items: stretch; }
.budget__cur {
  display: inline-flex;
  flex-shrink: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  overflow: hidden;
}
.budget__curbtn {
  display: grid; place-items: center;
  width: 2.5rem;
  font-size: var(--t-lead);
  color: var(--text-2);
  background: var(--surface);
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.budget__cur label:last-of-type { border-left: 1px solid var(--line-strong); }
.budget__cur input:checked + .budget__curbtn { background: var(--accent); color: var(--accent-ink); }
.budget__cur input:focus-visible + .budget__curbtn { outline: 2px solid var(--focus); outline-offset: -2px; }
.budget__amount { flex: 1 1 auto; min-width: 0; }

.select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-2) 50%),
                    linear-gradient(135deg, var(--text-2) 50%, transparent 50%);
  background-position: calc(100% - 20px) calc(50% + 1px), calc(100% - 14px) calc(50% + 1px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 2.75rem;
}

/* Submit states: idle, loading, success, error */
.formstate { display: flex; align-items: center; gap: var(--s-3); min-height: 1.5rem; font-size: var(--t-sm); }
.formstate[data-state="idle"] { display: none; }
.formstate[data-state="error"] { color: var(--accent-text); }
.formstate[data-state="success"] { color: var(--text); }

.spinner {
  width: 1.05em; height: 1.05em; flex-shrink: 0;
  border: 2px solid currentColor; border-right-color: transparent;
  border-radius: var(--r-full);
  animation: spin 720ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Skeleton (loading placeholder) ---------------------- */
.skeleton {
  border-radius: var(--r-lg);
  background:
    linear-gradient(90deg, var(--surface-2) 0%, var(--surface) 45%, var(--surface-2) 90%);
  background-size: 300% 100%;
  animation: shimmer 1.4s var(--ease-in-out) infinite;
}
@keyframes shimmer { from { background-position: 120% 0; } to { background-position: -60% 0; } }
.skeleton--text { height: 1em; border-radius: var(--r-sm); }

/* ---- Empty state ----------------------------------------- */
.empty {
  display: grid; justify-items: start; gap: var(--s-4);
  padding: var(--s-8) 0;
  max-width: 44ch;
}
.empty__icon { font-size: 1.75rem; color: var(--text-3); }

/* ============================================================
   Display utilities
   These sit after the component rules and carry !important on
   purpose: a utility that hides something must beat a component
   that sets its own display (.btn is inline-flex, for one).
   ============================================================ */
.hide-below-lg { display: none !important; }
@media (min-width: 1024px) { .hide-below-lg { display: inline-flex !important; } }

/* ============================================================
   Motion utilities
   Reveal is driven by IntersectionObserver (js/motion.js),
   never a scroll listener.
   ============================================================ */

@media (prefers-reduced-motion: no-preference) {
  [data-reveal] {
    opacity: 0;
    transform: translateY(22px);
    transition:
      opacity 700ms var(--ease-out),
      transform 700ms var(--ease-out);
    transition-delay: calc(var(--reveal-delay, 0) * 1ms);
  }
  [data-reveal][data-revealed="true"] { opacity: 1; transform: none; }

  /* Hero line mask reveal */
  .lineclip { display: block; overflow: hidden; padding-bottom: 0.08em; }
  .lineclip > span {
    display: block;
    transform: translateY(105%);
    animation: line-up 900ms var(--ease-out) both;
    animation-delay: calc(var(--i, 0) * 90ms + 120ms);
  }
  @keyframes line-up { to { transform: none; } }

  .fade-up {
    animation: fade-up 800ms var(--ease-out) both;
    animation-delay: calc(var(--i, 0) * 90ms + 260ms);
  }
  @keyframes fade-up {
    from { opacity: 0; transform: translateY(18px); }
    to   { opacity: 1; transform: none; }
  }
}

/* Under reduced motion nothing is hidden and nothing moves. */
@media (prefers-reduced-motion: reduce) {
  [data-reveal] { opacity: 1; transform: none; }
  .lineclip > span, .fade-up { animation: none; transform: none; opacity: 1; }
}

/* ============================================================
   Brightness slider
   A real range input, so keyboard, arrow keys, Home/End and
   screen readers all work with no extra scripting.
   ============================================================ */
.themeslider {
  display: flex; align-items: center; gap: var(--s-2);
  padding: 0 var(--s-3);
  height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  background: var(--surface);
  transition: border-color var(--dur-fast) var(--ease-out);
}
.themeslider:hover { border-color: var(--line-strong); }
.themeslider__icon { font-size: 0.95rem; color: var(--text-3); flex-shrink: 0; }

.themeslider__input {
  -webkit-appearance: none;
  appearance: none;
  width: 82px;
  height: 20px;
  background: transparent;
  cursor: default;          /* the pointer does not change while dragging the bar */
  margin: 0;
}
@media (min-width: 1100px) { .themeslider__input { width: 104px; } }

/* Track: night on the left, day on the right, so the control
   states what it does without a label. */
.themeslider__input::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: var(--r-full);
  background: linear-gradient(90deg, #1B1E24 0%, var(--accent) 52%, #F2F2F4 100%);
}
.themeslider__input::-moz-range-track {
  height: 4px;
  border-radius: var(--r-full);
  background: linear-gradient(90deg, #1B1E24 0%, var(--accent) 52%, #F2F2F4 100%);
}

.themeslider__input::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px; height: 14px;
  margin-top: -5px;
  border-radius: var(--r-full);
  background: var(--text);
  border: 2px solid var(--bg);
  box-shadow: 0 0 0 1px var(--line-strong);
  transition: transform var(--dur-fast) var(--ease-out);
}
.themeslider__input::-moz-range-thumb {
  width: 14px; height: 14px;
  border-radius: var(--r-full);
  background: var(--text);
  border: 2px solid var(--bg);
  box-shadow: 0 0 0 1px var(--line-strong);
  transition: transform var(--dur-fast) var(--ease-out);
}
.themeslider__input:hover::-webkit-slider-thumb { transform: scale(1.18); }
.themeslider__input:hover::-moz-range-thumb { transform: scale(1.18); }
.themeslider__input:focus-visible { outline: 2px solid var(--focus); outline-offset: 4px; border-radius: var(--r-full); }

@media (max-width: 380px) { .themeslider__input { width: 56px; } }
