@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@400;500&family=Caveat:wght@600;700&display=swap');

:root {
  --bg: #0B1410;
  --surface: #12201A;
  --surface-alt: #1A2E23;
  --border: #234636;
  --text: #EAF3EC;
  --text-muted: #86A695;
  --green: #4ADE80;
  --green-soft: rgba(74, 222, 128, 0.14);
  --green-dim: #2F9E63;
  --amber: #E8A33D;
  --amber-soft: rgba(232, 163, 61, 0.14);
  --danger: #EF6B6B;
  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --font-hand: 'Caveat', cursive;
  --radius: 10px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.5;
  position: relative;
}

/* subtle grain texture over the whole page, doesn't block clicks */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 999;
  opacity: 0.035;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

h1, h2, h3, .brand { font-family: var(--font-display); letter-spacing: -0.01em; }

a { color: inherit; text-decoration: none; }
.mono { font-family: var(--font-mono); }

/* ---------- Top nav ---------- */
.topnav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 40px;
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 20;
}

.brand {
  font-weight: 700;
  font-size: 1.15rem;
  display: flex;
  align-items: center;
  gap: 9px;
}

.brand .dot {
  width: 16px;
  height: 16px;
  background-image: url('/favicon.svg');
  background-size: cover;
  border-radius: 4px;
  transform: rotate(-6deg);
}

.nav-links {
  display: flex;
  gap: 28px;
  font-size: 0.92rem;
  color: var(--text-muted);
}

.nav-links a { position: relative; }
.nav-links a:hover { color: var(--text); }
.nav-links a::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: -4px;
  height: 2px;
  background: var(--amber);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.2s ease;
}
.nav-links a:hover::after { transform: scaleX(1); }

.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 4px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
}
.nav-toggle span { width: 22px; height: 2px; background: var(--text); border-radius: 2px; }

/* ---------- Hero ---------- */
.hero { padding: 90px 40px 60px; max-width: 1100px; margin: 0 auto; position: relative; }

.eyebrow {
  font-family: var(--font-hand);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--amber);
  display: inline-block;
  margin-bottom: 12px;
  transform: rotate(-2deg);
}

.hero h1 {
  font-size: clamp(2.4rem, 5vw, 3.6rem);
  font-weight: 700;
  margin: 0 0 20px;
  max-width: 20ch;
}

.hero h1 .underline {
  position: relative;
  white-space: nowrap;
}
.hero h1 .underline::after {
  content: '';
  position: absolute;
  left: -2%; right: -2%; bottom: -2px;
  height: 8px;
  background: var(--green-soft);
  z-index: -1;
  transform: rotate(-1deg);
}

.hero p { color: var(--text-muted); font-size: 1.05rem; max-width: 52ch; margin-bottom: 32px; }
.hero-actions { display: flex; gap: 14px; flex-wrap: wrap; }

/* ---------- Status strip ---------- */
.status-strip {
  max-width: 1100px; margin: 0 auto 70px; padding: 0 40px;
  display: grid; grid-template-columns: repeat(3, 1fr);
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
}
.status-cell { padding: 24px 28px; border-right: 1px solid var(--border); background: var(--surface); }
.status-cell:last-child { border-right: none; }
.status-label { font-family: var(--font-mono); font-size: 0.72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 8px; }
.status-value { font-family: var(--font-display); font-size: 1.8rem; font-weight: 600; }
.status-bar { margin-top: 12px; height: 3px; background: var(--surface-alt); border-radius: 2px; overflow: hidden; }
.status-bar span { display: block; height: 100%; background: var(--green); width: 0%; transition: width 0.8s ease; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 11px 20px; border-radius: 8px; font-size: 0.92rem; font-weight: 500; cursor: pointer; border: 1px solid transparent; }
.btn-primary { background: var(--green); color: #0B1410; font-weight: 600; }
.btn-primary:hover { background: #63e695; }
.btn-ghost { border-color: var(--border); color: var(--text); background: transparent; }
.btn-ghost:hover { border-color: var(--amber); }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--border); }
.btn-danger:hover { border-color: var(--danger); }

/* ---------- Search bar ---------- */
.search-row { margin-bottom: 24px; position: relative; max-width: 480px; }
.search-input {
  width: 100%; padding: 13px 16px 13px 40px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; color: var(--text);
  font-family: var(--font-body); font-size: 0.95rem;
}
.search-row::before {
  content: '⌕';
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); font-size: 1.1rem; pointer-events: none;
}
.search-input::placeholder { color: var(--text-muted); }
.search-input:focus { outline: none; border-color: var(--green); }

/* ---------- Recently opened chips ---------- */
.recents-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 32px; }
.recents-label { font-family: var(--font-hand); font-size: 1.05rem; color: var(--amber); display: flex; align-items: center; margin-right: 6px; }
.recent-chip { padding: 6px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; font-size: 0.82rem; color: var(--text-muted); cursor: pointer; }
.recent-chip:hover { border-color: var(--green); color: var(--text); }

/* ---------- Page section wrapper ---------- */
.section { max-width: 1100px; margin: 0 auto; padding: 0 40px 80px; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 22px; }
.section-head h2 { font-size: 1.3rem; margin: 0; }
.section-head .count { font-family: var(--font-mono); font-size: 0.78rem; color: var(--text-muted); }

/* ---------- Split layout (apps | photos) ---------- */
.split-grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0 32px;
  align-items: start;
}

.split-divider {
  width: 1px;
  align-self: stretch;
  position: relative;
  background: repeating-linear-gradient(
    to bottom,
    var(--border) 0, var(--border) 6px, transparent 6px, transparent 12px
  );
}

.split-col { min-width: 0; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 16px;
}

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; cursor: pointer; transition: border-color 0.15s ease, transform 0.15s ease;
}
.card:nth-child(odd):hover { transform: rotate(-0.6deg) translateY(-2px); }
.card:nth-child(even):hover { transform: rotate(0.6deg) translateY(-2px); }
.card:hover { border-color: var(--green-dim); }

.app-icon {
  width: 36px; height: 36px; border-radius: 8px; background: var(--green-soft); color: var(--green);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 700; margin-bottom: 14px;
}
.card h3 { font-size: 0.98rem; margin: 0 0 6px; }
.card p { color: var(--text-muted); font-size: 0.85rem; margin: 0; }

.empty-state { border: 1px dashed var(--border); border-radius: var(--radius); padding: 32px 20px; text-align: center; color: var(--text-muted); grid-column: 1 / -1; font-size: 0.9rem; }

/* ---------- Photo grid: polaroid style ---------- */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 20px 16px; }

.photo-card {
  background: #f4f1e8;
  border-radius: 4px;
  padding: 8px 8px 14px;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0,0,0,0.35);
  transition: transform 0.18s ease;
}
.photo-card:nth-child(3n+1) { transform: rotate(-2deg); }
.photo-card:nth-child(3n+2) { transform: rotate(1.5deg); }
.photo-card:nth-child(3n)   { transform: rotate(-1deg); }
.photo-card:hover { transform: rotate(0deg) scale(1.03); }

.photo-card img { width: 100%; height: 130px; object-fit: cover; display: block; border-radius: 2px; }
.photo-caption { padding-top: 10px; color: #333; font-family: var(--font-hand); font-weight: 600; font-size: 1.05rem; text-align: center; }

/* ---------- Inline viewer (apps + photos) ---------- */
.app-viewer { display: none; max-width: 1100px; margin: 0 auto; padding: 0 40px 80px; }
.app-viewer.active { display: block; }

.app-viewer-bar {
  display: flex; align-items: center; justify-content: space-between; padding: 12px 16px;
  background: var(--surface); border: 1px solid var(--border); border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0; flex-wrap: wrap; gap: 8px;
}
.app-viewer-bar-left { display: flex; align-items: center; gap: 12px; }

.back-btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px;
  border: 1px solid var(--border); background: transparent; color: var(--text);
  font-family: var(--font-body); font-size: 0.88rem; cursor: pointer;
}
.back-btn:hover { border-color: var(--amber); }

.app-viewer-title { font-weight: 600; font-size: 0.95rem; }
.app-viewer-open { font-size: 0.82rem; color: var(--text-muted); }
.app-viewer-open:hover { color: var(--green); }

.app-viewer-frame-wrap {
  border: 1px solid var(--border); border-radius: 0 0 var(--radius) var(--radius);
  overflow: hidden; background: var(--surface);
}
.app-viewer-frame-wrap iframe { width: 100%; height: 75vh; border: none; display: block; }

.app-viewer-image-wrap {
  border: 1px solid var(--border); border-radius: 0 0 var(--radius) var(--radius);
  overflow: hidden; background: #0a0a0a; display: flex; align-items: center; justify-content: center;
  min-height: 300px;
}
.app-viewer-image-wrap img { max-width: 100%; max-height: 78vh; display: block; }

/* ---------- Admin layout ---------- */
.admin-shell { display: flex; min-height: 100vh; }
.sidebar { width: 220px; border-right: 1px solid var(--border); padding: 28px 20px; flex-shrink: 0; }
.sidebar-link { display: block; padding: 10px 12px; border-radius: 8px; color: var(--text-muted); font-size: 0.9rem; margin-bottom: 4px; cursor: pointer; }
.sidebar-link.active, .sidebar-link:hover { background: var(--surface); color: var(--text); }
.admin-content { flex: 1; padding: 40px; max-width: 900px; }
.panel { display: none; }
.panel.active { display: block; }

.form-row { margin-bottom: 16px; }
.form-row label { display: block; font-size: 0.82rem; color: var(--text-muted); margin-bottom: 6px; }
.form-row input, .form-row textarea {
  width: 100%; padding: 10px 12px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-family: var(--font-body); font-size: 0.92rem;
}
.form-row input:focus, .form-row textarea:focus { outline: none; border-color: var(--green); }

.list-row { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 10px; }
.list-row-main { display: flex; flex-direction: column; }
.list-row-main span:first-child { font-weight: 500; }
.list-row-main span:last-child { color: var(--text-muted); font-size: 0.82rem; }

.login-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card { width: 340px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 32px; }
.login-card h2 { margin-top: 0; }

.toast {
  position: fixed; bottom: 24px; right: 24px; background: var(--surface-alt); border: 1px solid var(--border);
  padding: 12px 18px; border-radius: 8px; font-size: 0.88rem; opacity: 0; transform: translateY(8px);
  transition: all 0.25s ease; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }

/* ---------- Footer ---------- */
.site-footer {
  max-width: 1100px; margin: 0 auto; padding: 20px 40px 50px;
  color: var(--text-muted); font-size: 0.82rem; display: flex; justify-content: space-between;
  border-top: 1px solid var(--border); flex-wrap: wrap; gap: 8px;
}
.site-footer .hand { font-family: var(--font-hand); color: var(--amber); font-size: 1.05rem; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- Mobile ---------- */
@media (max-width: 860px) {
  .split-grid { grid-template-columns: 1fr; gap: 40px 0; }
  .split-divider { display: none; }
}

@media (max-width: 720px) {
  .topnav, .hero, .section, .app-viewer, .site-footer { padding-left: 20px; padding-right: 20px; }
  .status-strip { padding: 0 20px; grid-template-columns: 1fr; }
  .status-cell { border-right: none; border-bottom: 1px solid var(--border); }
  .admin-shell { flex-direction: column; }
  .sidebar { width: auto; border-right: none; border-bottom: 1px solid var(--border); display: flex; gap: 8px; overflow-x: auto; }
  .app-viewer-frame-wrap iframe { height: 65vh; }
  .hero { padding: 50px 20px 40px; }
  .hero h1 { font-size: 2.1rem; }

  .nav-toggle { display: flex; }
  .nav-links {
    position: absolute; top: 100%; left: 0; right: 0; background: var(--surface);
    border-bottom: 1px solid var(--border); flex-direction: column; gap: 0;
    max-height: 0; overflow: hidden; transition: max-height 0.2s ease;
  }
  .nav-links.open { max-height: 220px; }
  .nav-links a { padding: 14px 20px; border-top: 1px solid var(--border); }

  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
  .photo-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
}
