/* ====================================================================
   App Arcade — styles
   Aesthetic: warm paper, academic serif display, confident colour
   ==================================================================== */

:root {
  /* palette */
  --paper:        #f6f1e7;
  --paper-deep:   #ece4d2;
  --ink:          #1a1814;
  --ink-soft:     #4a4339;
  --ink-mute:     #8a8172;
  --rule:         #d8cfb9;
  --card:         #fffdf7;
  --accent:       #c65d30;      /* terracotta */
  --accent-deep:  #9a3f17;
  --navy:         #1e2a4a;
  --lime:         #6b7a1f;
  --plum:         #6b2a4a;
  --ok:           #2f6b3d;

  /* type */
  --serif: "Fraunces", "Iowan Old Style", Georgia, serif;
  --sans:  "Figtree", system-ui, -apple-system, sans-serif;

  /* geometry */
  --radius:   14px;
  --radius-l: 22px;
  --maxw:     1180px;

  /* motion */
  --ease: cubic-bezier(.2,.7,.2,1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(1200px 600px at 85% -10%, rgba(198,93,48,.08), transparent 60%),
    radial-gradient(900px 500px at -10% 0%, rgba(30,42,74,.06), transparent 60%),
    var(--paper);
  overflow-x: hidden;
}

/* subtle grain overlay — gives the paper feel */
.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: .35;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='140'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.1  0 0 0 0 0.09  0 0 0 0 0.07  0 0 0 .09 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}

/* ============ HERO ============ */

.hero {
  position: relative;
  z-index: 2;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: clamp(28px, 5vw, 56px) clamp(20px, 4vw, 48px) 32px;
}

.hero-inner {
  position: relative;
  padding-bottom: 36px;
  border-bottom: 1px solid var(--rule);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--sans);
  font-weight: 600;
  font-size: .82rem;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.brand-mark {
  color: var(--accent);
  font-size: 1rem;
}

.hero-title {
  margin: 18px 0 12px;
  font-family: var(--serif);
  font-weight: 500;
  font-optical-sizing: auto;
  font-variation-settings: "opsz" 144, "SOFT" 50;
  line-height: .95;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.hero-title-line-1 {
  display: block;
  font-size: clamp(28px, 4vw, 44px);
  font-style: italic;
  font-weight: 400;
  color: var(--ink-soft);
}

.hero-title-line-2 {
  display: block;
  font-size: clamp(56px, 11vw, 128px);
  font-weight: 600;
  margin-top: -4px;
}

.hero-tag {
  margin: 0;
  font-size: clamp(16px, 2vw, 18px);
  color: var(--ink-soft);
  max-width: 520px;
}

/* ============ CONTROLS ============ */

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  margin-top: 28px;
}

.search-wrap {
  position: relative;
  flex: 1 1 280px;
  min-width: 220px;
  max-width: 420px;
}

.search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--ink-mute);
}

#search {
  width: 100%;
  font-family: var(--sans);
  font-size: 15px;
  padding: 13px 16px 13px 44px;
  border: 1px solid var(--rule);
  background: var(--card);
  border-radius: 999px;
  color: var(--ink);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}

#search::placeholder { color: var(--ink-mute); }

#search:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(198,93,48,.14);
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--rule);
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  transition: all .15s var(--ease);
}

.chip:hover {
  border-color: var(--ink-soft);
  color: var(--ink);
}

.chip.is-active {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}

/* ============ ARCADE META ============ */

.arcade {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 8px clamp(20px, 4vw, 48px) 80px;
  position: relative;
  z-index: 2;
}

.arcade-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 2px 22px;
  font-size: 13px;
  color: var(--ink-mute);
  letter-spacing: .02em;
}

.app-count {
  font-weight: 600;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: .14em;
  font-size: 12px;
}

.meta-divider { color: var(--rule); }

/* ============ GRID ============ */

.grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
}

.card {
  --card-accent: var(--accent);
  position: relative;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--radius-l);
  padding: 22px 22px 20px;
  cursor: pointer;
  overflow: hidden;
  transition: transform .25s var(--ease), border-color .2s var(--ease), box-shadow .3s var(--ease);
  display: flex;
  flex-direction: column;
  min-height: 220px;
  text-align: left;
  font-family: inherit;
  color: inherit;
  animation: card-in .5s var(--ease) both;
}

@keyframes card-in {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

.card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  box-shadow: inset 0 -60px 80px -60px rgba(0,0,0,.05);
}

.card::after {
  /* accent corner */
  content: "";
  position: absolute;
  top: 0; right: 0;
  width: 54px; height: 54px;
  background: var(--card-accent);
  clip-path: polygon(100% 0, 0 0, 100% 100%);
  opacity: .9;
  transition: width .3s var(--ease), height .3s var(--ease);
}

.card:hover {
  transform: translateY(-3px);
  border-color: var(--card-accent);
  box-shadow: 0 18px 40px -20px rgba(26,24,20,.2);
}

.card:hover::after {
  width: 72px;
  height: 72px;
}

.card:focus-visible {
  outline: 2px solid var(--card-accent);
  outline-offset: 3px;
}

.card-icon {
  font-size: 42px;
  line-height: 1;
  margin-bottom: 14px;
  filter: drop-shadow(0 2px 0 rgba(0,0,0,.08));
}

.card-title {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 22px;
  line-height: 1.15;
  letter-spacing: -0.01em;
  margin: 0 0 8px;
  color: var(--ink);
  padding-right: 36px; /* avoid the corner accent */
}

.card-desc {
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink-soft);
  margin: 0 0 16px;
  flex: 1;
}

.card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 14px;
  border-top: 1px dashed var(--rule);
}

.card-teacher {
  font-size: 12px;
  color: var(--ink-mute);
  letter-spacing: .04em;
}

.card-teacher strong {
  color: var(--ink-soft);
  font-weight: 600;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 12px;
  padding: 0;
  list-style: none;
}

.card-tag {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: 4px 8px;
  border-radius: 4px;
  background: var(--paper-deep);
  color: var(--ink-soft);
}

.card-launch {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--card-accent);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.card-launch::after {
  content: "→";
  transition: transform .2s var(--ease);
}

.card:hover .card-launch::after {
  transform: translateX(3px);
}

/* ============ EMPTY STATE ============ */

.empty {
  text-align: center;
  padding: 80px 20px;
  color: var(--ink-soft);
}

.empty-icon { font-size: 48px; margin-bottom: 8px; }
.empty-title {
  font-family: var(--serif);
  font-size: 24px;
  margin: 0 0 6px;
  color: var(--ink);
}
.empty-sub { margin: 0; color: var(--ink-mute); }

/* ============ FOOTER ============ */

.site-foot {
  position: relative;
  z-index: 2;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 32px clamp(20px, 4vw, 48px) 48px;
  border-top: 1px solid var(--rule);
  color: var(--ink-mute);
  font-size: 13px;
  text-align: center;
}

.site-foot p { margin: 0; }

/* ============ MODAL ============ */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(26, 24, 20, .82);
  backdrop-filter: blur(8px) saturate(120%);
  -webkit-backdrop-filter: blur(8px) saturate(120%);
  z-index: 100;
  display: none;
  flex-direction: column;
}

.modal[aria-hidden="false"] {
  display: flex;
  animation: modal-in .25s var(--ease);
}

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

.modal-chrome {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 12px clamp(14px, 3vw, 24px);
  background: var(--card);
  border-bottom: 1px solid var(--rule);
}

.modal-chrome-right { justify-self: end; }

.chrome-title {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 17px;
  color: var(--ink);
  max-width: 50vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chrome-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--sans);
  font-weight: 500;
  font-size: 13px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--rule);
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  text-decoration: none;
  transition: all .15s var(--ease);
}

.chrome-btn:hover {
  background: var(--paper-deep);
  border-color: var(--ink-soft);
  color: var(--ink);
}

.close-btn { padding-left: 8px; }

.modal-frame-wrap {
  flex: 1;
  position: relative;
  background: #fff;
  overflow: hidden;
}

#app-frame {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

/* ============ RESPONSIVE ============ */

@media (max-width: 640px) {
  .grid { grid-template-columns: 1fr; }
  .hero-title-line-2 { font-size: clamp(52px, 16vw, 88px); }
  .chrome-btn span { display: none; }
  .chrome-btn { padding: 8px; }
  .close-btn { padding: 8px; }
  .chrome-title { max-width: 60vw; font-size: 15px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
