@font-face {
  font-family: "DINNext";
  src: url("fonts/DINNext-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "DINNext";
  src: url("fonts/DINNext-Medium.ttf") format("truetype");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "DINNext";
  src: url("fonts/DINNext-Bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --brand-red: #bd3532;
  --brand-red-dark: #9e2b29;
  --brand-grey: #6d6e6f;
  --ink: #2a2a2b;
  --bg: #f7f6f5;
  --surface: #ffffff;
  --line: #e8e6e4;
  --page-pad: clamp(1rem, 4vw, 1.5rem);
  --max: 1100px;
  --font: "DINNext", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(ellipse 80% 50% at 100% -10%, rgba(189, 53, 50, 0.08), transparent 55%),
    radial-gradient(ellipse 60% 40% at -10% 20%, rgba(189, 53, 50, 0.05), transparent 50%),
    var(--bg);
  min-height: 100dvh;
  line-height: 1.45;
  display: flex;
  flex-direction: column;
}

main {
  flex: 1;
  width: 100%;
}

a {
  color: inherit;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.header-inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0.85rem var(--page-pad);
  padding-top: max(0.85rem, env(safe-area-inset-top));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.back-btn {
  flex-shrink: 0;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--brand-grey);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 0.55rem 0.8rem;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
  white-space: nowrap;
}

.back-btn:hover {
  border-color: var(--brand-red);
  color: var(--brand-red);
}

.hidden {
  display: none !important;
}

body.viewer-open {
  overflow: hidden;
  height: 100dvh;
}

body.viewer-open main {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}

.viewer {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  width: 100%;
}

.viewer-bar {
  max-width: none;
  padding: 0.75rem var(--page-pad);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.viewer-bar h1 {
  font-family: var(--font);
  font-size: clamp(0.95rem, 2.5vw, 1.15rem);
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.3;
}

.viewer iframe {
  flex: 1;
  width: 100%;
  min-height: 0;
  border: 0;
  background: #fff;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.brand img.wordmark {
  height: clamp(32px, 8vw, 42px);
  width: auto;
  max-width: min(160px, 48vw);
  object-fit: contain;
  display: block;
  flex-shrink: 0;
}

.brand img.mark {
  height: clamp(28px, 7vw, 36px);
  width: auto;
  display: block;
  flex-shrink: 0;
}

.brand-meta {
  display: none;
  font-size: 0.78rem;
  color: var(--brand-grey);
  border-left: 1px solid var(--line);
  padding-left: 0.85rem;
  line-height: 1.3;
  white-space: nowrap;
}

.hero {
  max-width: var(--max);
  margin: 0 auto;
  padding: clamp(1.5rem, 4vw, 2.5rem) var(--page-pad) 1rem;
  animation: rise 0.45s ease both;
}

.hero h1 {
  font-family: var(--font);
  font-size: clamp(1.6rem, 5vw, 2.25rem);
  font-weight: 700;
  letter-spacing: -0.03em;
}

.hero p {
  margin-top: 0.4rem;
  color: var(--brand-grey);
  font-size: clamp(0.92rem, 2.5vw, 1rem);
}

.grid {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 var(--page-pad) clamp(2rem, 6vw, 3rem);
  padding-bottom: max(clamp(2rem, 6vw, 3rem), env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.85rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  padding: clamp(1.1rem, 3vw, 1.35rem);
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  min-height: 0;
  transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
  animation: rise 0.45s ease both;
}

.card h2 {
  font-family: var(--font);
  font-size: clamp(1rem, 2.8vw, 1.12rem);
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.35;
  flex: 1;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  padding: 0.85rem 1rem;
  min-height: 48px;
  border: none;
  border-radius: 0;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
  background: var(--brand-red);
  color: #fff;
  width: 100%;
  touch-action: manipulation;
}

.btn:hover {
  background: var(--brand-red-dark);
}

.btn:active {
  transform: scale(0.98);
}

.site-footer {
  border-top: 1px solid var(--line);
  background: var(--surface);
  padding: 1.1rem var(--page-pad);
  padding-bottom: max(1.1rem, env(safe-area-inset-bottom));
}

.footer-inner {
  max-width: var(--max);
  margin: 0 auto;
  color: var(--brand-grey);
  font-size: 0.82rem;
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
}

.footer-brand img {
  height: 22px;
  width: auto;
  flex-shrink: 0;
}

.footer-brand span {
  overflow-wrap: anywhere;
}

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

/* Tablet: 2 columns */
@media (min-width: 640px) {
  .grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
  }

  .card {
    min-height: 168px;
  }

  .brand-meta {
    display: block;
  }
}

/* Desktop: 3 columns */
@media (min-width: 960px) {
  .grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 1.1rem;
  }

  .card {
    min-height: 180px;
  }
}

/* Narrow phones */
@media (max-width: 420px) {
  .brand img.mark {
    display: none;
  }

  .brand-meta {
    display: none;
  }
}

/* Prefer no hover lift on touch devices */
@media (hover: hover) and (pointer: fine) {
  .card:hover {
    border-color: color-mix(in srgb, var(--brand-red) 45%, var(--line));
    transform: translateY(-2px);
    box-shadow: 0 10px 28px rgba(42, 42, 43, 0.06);
  }
}

/* Admin (hidden sign-in at #admin) */
.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.admin-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.admin-badge {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--brand-red);
  border: 1px solid color-mix(in srgb, var(--brand-red) 40%, var(--line));
  padding: 0.3rem 0.5rem;
}

.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--page-pad);
  background: rgba(42, 42, 43, 0.45);
}

.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  box-shadow: 0 18px 48px rgba(42, 42, 43, 0.18);
}

.login-card h2 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.login-card label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--brand-grey);
}

.login-card input {
  font: inherit;
  font-size: 1rem;
  color: var(--ink);
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--surface);
}

.login-card input:focus {
  outline: 2px solid var(--brand-red);
  outline-offset: -1px;
}

.login-error {
  min-height: 1.2em;
  font-size: 0.85rem;
  color: var(--brand-red);
}

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

.login-actions .btn {
  flex: 1;
  min-height: 44px;
}

.login-actions .btn:disabled {
  opacity: 0.7;
  cursor: progress;
}

/* Admin editing */
.grid-status {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 var(--page-pad) 1rem;
  color: var(--brand-grey);
  font-size: 0.92rem;
}

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

.card-actions .btn {
  flex: 1;
}

.btn-secondary {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  flex: 0 0 auto !important;
  width: auto;
  padding: 0.85rem 1.1rem;
}

.btn-secondary:hover {
  background: var(--bg);
  border-color: var(--brand-red);
  color: var(--brand-red);
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: -0.5rem;
}

.tag {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--brand-grey);
  border: 1px solid var(--line);
  padding: 0.15rem 0.45rem;
}

.tag-public {
  color: #2d6a3e;
  border-color: #b9d8c1;
}

.login-card label.check {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  color: var(--ink);
}

.login-card label.check input {
  width: 18px;
  height: 18px;
  accent-color: var(--brand-red);
}

.back-btn.danger {
  color: var(--brand-red);
  margin-right: auto;
}

@media (max-width: 520px) {
  .admin-badge {
    display: none;
  }
}
