/* ============================================================
   PlayDailyz — shared stylesheet
   Palette: warm cream / coral / teal / sunny yellow / violet
   Type: Space Grotesk (display) + Inter (body)
   ============================================================ */

:root {
  --bg: #FFF8EC;
  --card: #FFFFFF;
  --primary: #FF6B4A;
  --primary-deep: #D84A2E;
  --secondary: #1FA398;
  --secondary-deep: #147F76;
  --yellow: #FFC94D;
  --violet: #6C5CE7;
  --ink: #23262B;
  --muted: #746B62;
  --line: #F0E2CC;
  --white: #FFFFFF;

  --font-display: 'Space Grotesk', -apple-system, sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

  --radius-sm: 12px;
  --radius-md: 18px;
  --radius-lg: 26px;
  --shadow-card: 0 4px 18px -6px rgba(35,38,43,0.12);
}

[data-theme="dark"] {
  --bg: #14171C;
  --card: #1E222A;
  --primary: #FF8064;
  --primary-deep: #FF6B4A;
  --secondary: #3FCBBE;
  --secondary-deep: #1FA398;
  --ink: #F1EDE6;
  --muted: #A79E93;
  --line: #2C313A;
  --white: #1E222A;
  --shadow-card: 0 4px 18px -6px rgba(0,0,0,0.4);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  padding-bottom: 90px;
  transition: background-color .2s ease, color .2s ease;
}

h1, h2, h3, h4 { font-family: var(--font-display); color: var(--ink); line-height: 1.15; margin: 0 0 .5rem; font-weight: 700; }
p { margin: 0 0 1rem; }
.muted { color: var(--muted); font-size: .9rem; }
a { color: var(--secondary-deep); }
button { font-family: var(--font-body); cursor: pointer; }
.hidden { display: none !important; }
* { transition: background-color .2s ease, color .2s ease, border-color .2s ease; }

html[lang="ar"] body { font-family: 'Noto Kufi Arabic', var(--font-body); }

/* ---------- Header ---------- */

#site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.1rem .7rem;
  gap: .6rem;
  max-width: 900px;
  margin: 0 auto;
}
.brand-link { display: flex; align-items: center; gap: .5rem; text-decoration: none; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px;
  background: var(--primary);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.brand-mark svg { width: 16px; height: 16px; }
.brand-text { font-family: var(--font-display); font-size: 1.3rem; font-weight: 700; color: var(--ink); }
.brand-text span { color: var(--secondary-deep); }

.header-controls { display: flex; align-items: center; gap: .45rem; }
#lang-select {
  width: auto; padding: .4rem .55rem; font-size: .75rem; font-weight: 700;
  border-radius: 999px; border: 1.5px solid var(--line); background: var(--card); color: var(--ink);
}
#theme-toggle, .icon-btn {
  background: var(--card); border: 1.5px solid var(--line); border-radius: 50%;
  width: 36px; height: 36px; font-size: 1rem; display: flex; align-items: center; justify-content: center;
}

/* ---------- Layout ---------- */

main { max-width: 900px; margin: 0 auto; padding: 0 1.1rem 1rem; }
section { margin-bottom: 1.8rem; }

.card {
  background: var(--card);
  border-radius: var(--radius-md);
  padding: 1.2rem;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-card);
}

.section-header { margin-bottom: 1rem; display: flex; align-items: baseline; justify-content: space-between; gap: .6rem; flex-wrap: wrap; }
.section-header h2 { font-size: 1.3rem; }
.section-header p { color: var(--muted); font-size: .9rem; margin: 0; }
.section-header a { font-size: .85rem; font-weight: 700; text-decoration: none; white-space: nowrap; }

.btn-primary {
  background: var(--primary); color: var(--white); border: none; border-radius: 999px;
  padding: .8rem 1.4rem; font-size: .95rem; font-weight: 700;
}
[data-theme="dark"] .btn-primary { color: #14171C; }
.btn-primary:hover { background: var(--primary-deep); }
.btn-secondary {
  background: transparent; color: var(--ink); border: 1.5px solid var(--line); border-radius: 999px;
  padding: .65rem 1.2rem; font-size: .88rem; font-weight: 700;
}
.btn-secondary:hover { border-color: var(--primary); }

input, select, textarea {
  font-family: var(--font-body); font-size: 1rem; padding: .7rem .9rem;
  border-radius: var(--radius-sm); border: 1.5px solid var(--line);
  background: var(--card); color: var(--ink); width: 100%;
}
input:focus, select:focus, button:focus-visible { outline: 3px solid var(--secondary); outline-offset: 1px; }

/* ---------- Hero ---------- */

.hero {
  background: linear-gradient(150deg, var(--violet), #8B7CF0);
  color: var(--white);
  border-radius: var(--radius-lg);
  padding: 1.8rem 1.5rem;
  margin: .3rem 0 1.6rem;
}
.hero h1 { color: var(--white); font-size: 1.7rem; margin-bottom: .3rem; }
.hero p { color: rgba(255,255,255,.88); margin-bottom: 1rem; font-size: .95rem; }
.hero-date { font-size: .8rem; opacity: .85; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; margin-bottom: .4rem; }

/* ---------- Grid cards (games, features) ---------- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: .8rem;
}
.tile {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 1rem .8rem;
  text-align: center;
  text-decoration: none;
  color: var(--ink);
  display: flex; flex-direction: column; align-items: center; gap: .5rem;
  box-shadow: var(--shadow-card);
}
.tile:hover { border-color: var(--primary); transform: translateY(-2px); }
.tile-icon {
  width: 52px; height: 52px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem;
}
.tile-name { font-family: var(--font-display); font-weight: 700; font-size: .92rem; }
.tile-tag {
  font-size: .65rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
  padding: .12rem .5rem; border-radius: 999px; color: var(--white);
}

/* ---------- Bottom nav ---------- */

.tab-bar {
  position: fixed; bottom: 0; left: 0; right: 0;
  display: flex; background: var(--card); border-top: 1px solid var(--line);
  padding: .4rem .2rem calc(.4rem + env(safe-area-inset-bottom));
  z-index: 50;
}
.tab-btn {
  flex: 1; background: none; border: none; text-decoration: none;
  display: flex; flex-direction: column; align-items: center; gap: .15rem;
  font-size: .66rem; color: var(--muted); padding: .3rem 0; border-radius: var(--radius-sm);
}
.tab-btn .icon { font-size: 1.2rem; }
.tab-btn.active { color: var(--primary); }

/* ---------- Share button ---------- */

.share-row { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: 1rem; }
.share-btn {
  background: var(--secondary); color: var(--white); border: none; border-radius: 999px;
  padding: .7rem 1.3rem; font-size: .88rem; font-weight: 700; display: flex; align-items: center; gap: .4rem;
}
.share-btn:hover { background: var(--secondary-deep); }
.share-toast {
  position: fixed; bottom: 100px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: .6rem 1.1rem; border-radius: 999px;
  font-size: .85rem; font-weight: 600; z-index: 100; opacity: 0; pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
}
.share-toast.show { opacity: 1; transform: translateX(-50%) translateY(-6px); }

/* ---------- Footer ---------- */

#site-footer { text-align: center; padding: 1.6rem 1rem 1rem; font-size: .78rem; color: var(--muted); }
#site-footer a { color: var(--muted); }
body.no-tabbar { padding-bottom: 24px; }

/* ---------- Share popover ---------- */

.share-popover-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: flex; align-items: flex-end; justify-content: center; z-index: 200;
}
.share-popover {
  background: var(--card); border-radius: 22px 22px 0 0; padding: 1.4rem 1.2rem calc(1.4rem + env(safe-area-inset-bottom));
  width: 100%; max-width: 420px; position: relative;
}
@media (min-width: 480px) {
  .share-popover-overlay { align-items: center; }
  .share-popover { border-radius: 22px; }
}
.share-popover-title { font-family: var(--font-display); font-weight: 700; font-size: 1.05rem; margin-bottom: 1rem; text-align: center; }
.share-popover-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: .8rem; }
.share-option {
  display: flex; flex-direction: column; align-items: center; gap: .4rem;
  text-decoration: none; color: var(--ink); background: none; border: none; font-family: var(--font-body); font-size: .72rem; font-weight: 600;
}
.share-option-icon {
  width: 48px; height: 48px; border-radius: 50%; color: #fff; font-weight: 700; font-size: 1.1rem;
  display: flex; align-items: center; justify-content: center;
}
.share-popover-close {
  position: absolute; top: .8rem; right: .8rem; background: var(--bg); border: none; border-radius: 50%;
  width: 30px; height: 30px; font-size: .9rem; color: var(--muted);
}
html[dir="rtl"] .share-popover-close { right: auto; left: .8rem; }

/* ---------- Game frame (shared by every game page) ---------- */

.game-page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; gap: .6rem; flex-wrap: wrap; }
.game-page-header h1 { font-size: 1.5rem; margin: 0; }
.game-frame {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 1.2rem; display: flex; flex-direction: column; align-items: center; gap: 1rem;
}
.game-status { font-family: var(--font-display); font-weight: 700; font-size: 1.05rem; text-align: center; min-height: 1.4em; }
.game-controls { display: flex; gap: .6rem; flex-wrap: wrap; justify-content: center; }
.game-instructions { font-size: .88rem; color: var(--muted); margin-top: .8rem; }

/* ---------- Breadcrumb / back link ---------- */

.back-link {
  display: inline-flex; align-items: center; gap: .4rem; font-size: .92rem; font-weight: 700;
  text-decoration: none; margin-bottom: 1rem; color: var(--ink);
  background: var(--card); border: 1.5px solid var(--line); border-radius: 999px; padding: .5rem 1rem;
}
.back-link:hover { color: var(--primary); border-color: var(--primary); }

/* ---------- Responsive ---------- */

@media (min-width: 640px) {
  .hero h1 { font-size: 2.1rem; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}

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