/* ============================================================
   kungla.me — Master Style (v1.16)
   Crafted in light and silence — by Urmas Kungla
   ============================================================ */

/* ------------------------------------------------------------
   Root Variables
------------------------------------------------------------ */
:root {
  --fg: #e9ecf1;
  --muted: #aeb7c6;
  --accent: #f6ca4f;
  --glass-dark: rgba(18,22,35,0.68);
  --glass-light: rgba(255,255,255,0.78);
  --focus-outline: #ffd84b;
}

/* ------------------------------------------------------------
   Reset & Base
------------------------------------------------------------ */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: 100vh;
  font-family: ui-serif, Georgia, "Times New Roman", serif;
  color: var(--fg);
  background: #0e1320;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ------------------------------------------------------------
   Typography
------------------------------------------------------------ */
section h1 { font-size: inherit; } /* ✅ fixes deprecated UA font size warning */

h1, h2, h3, h4, h5, h6 {
  font-family: inherit;
  font-weight: 600;
  margin: 0 0 .5rem;
}

h1 { font-size: clamp(1.8rem, 2.2vw + 1.2rem, 2.6rem); line-height: 1.25; }
h2 { font-size: clamp(1.5rem, 1.2vw + 1rem, 2rem); line-height: 1.3; }
h3 { font-size: clamp(1.25rem, 0.9vw + 0.9rem, 1.6rem); line-height: 1.35; }
h4 { font-size: 1.15rem; }
h5 { font-size: 1.05rem; }
h6 { font-size: 1rem; }

.subtitle {
  font-size: 1.05rem;
  color: var(--muted);
  margin-bottom: 1.2rem;
}

p {
  margin: 0.7rem auto;
  line-height: 1.7;
  font-size: 1.06rem;
  max-width: 55ch;
  color: var(--fg);
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.2s ease, filter 0.2s ease;
}

a:hover,
a:focus-visible {
  filter: brightness(1.15);
  outline: none;
}

a:focus-visible {
  box-shadow: 0 0 0 3px var(--focus-outline);
  border-radius: 4px;
}

/* ------------------------------------------------------------
   Aurora Background
------------------------------------------------------------ */
.aurora {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: radial-gradient(800px 600px at 20% 30%, rgba(255,80,200,0.12), transparent 70%),
              radial-gradient(1000px 700px at 80% 70%, rgba(0,200,255,0.12), transparent 70%),
              radial-gradient(900px 800px at 50% 50%, rgba(100,255,180,0.08), transparent 70%);
  background-repeat: no-repeat;
  background-size: 160% 160%;
  animation: auroraDrift 80s ease-in-out infinite alternate;
  filter: blur(0.5px) saturate(140%);
  transform: translateZ(0);
  will-change: background-position;
}

@keyframes auroraDrift {
  0% { background-position: 0% 0%, 100% 100%, 50% 50%; }
  50% { background-position: 80% 40%, 20% 80%, 60% 30%; }
  100% { background-position: 40% 70%, 0% 0%, 100% 50%; }
}

/* ------------------------------------------------------------
   Layout & Sections
------------------------------------------------------------ */
main {
  flex: 1 0 auto;
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  text-align: center;
  padding: clamp(6vh, 8vh, 12vh) 1.2rem clamp(10vh, 14vh, 18vh);
  animation: fadeIn 1.2s ease forwards 0.2s;
  opacity: 0;
}
@keyframes fadeIn { to { opacity: 1; } }

section, .card {
  max-width: 720px;
  width: min(92vw, 720px);
  background: linear-gradient(135deg, rgba(255,255,255,0.08), transparent 60%), var(--glass-dark);
  border: 1px solid #ffffff1a;
  border-radius: 24px;
  padding: 2.4rem 2rem;
  backdrop-filter: blur(14px) saturate(140%);
  box-shadow: 0 20px 60px rgba(0,0,0,0.6), inset 0 1px 0 #ffffff20;
  overflow: hidden;
  position: relative;
}
section::before, .card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 70% 30%, rgba(255,255,255,0.06), transparent 80%);
  animation: glassGlow 50s ease-in-out infinite alternate;
  opacity: 0.6;
  pointer-events: none;
}
@keyframes glassGlow {
  0% { opacity: 0.5; }
  50% { opacity: 0.7; }
  100% { opacity: 0.5; }
}

/* ------------------------------------------------------------
   Buttons & Controls
------------------------------------------------------------ */
.btn {
  display: inline-block;
  margin-top: 1.4rem;
  padding: 0.78rem 1.2rem;
  border-radius: 12px;
  font-weight: 700;
  color: #111;
  background: var(--accent);
  box-shadow: 0 8px 24px #ffd45133, inset 0 1px 0 #fff6;
  transition: transform 0.08s ease, box-shadow 0.15s ease, filter 0.15s ease;
}

.btn:hover,
.btn:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 10px 28px #ffd45144;
  filter: brightness(1.02);
  outline: none;
}

/* ------------------------------------------------------------
   Footer
------------------------------------------------------------ */
footer, #footer {
  flex-shrink: 0;
  position: relative;
  width: 100%;
  text-align: center;
  color: #aeb7c6bb;
  font-size: 0.9rem;
  z-index: 2;
  padding: 2rem 0 2.5rem;
  margin-top: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(6px) saturate(120%);
  background: transparent;
}
footer a, #footer a {
  color: inherit;
  text-decoration: none;
  padding: 0 0.6rem;
  margin: 0 0.2rem;
  transition: color 0.2s ease;
}
footer a:hover,
footer a:focus-visible {
  color: #ffd84b;
  text-decoration: underline;
}
.dot { opacity: 0.4; padding: 0 0.4rem; }
.ga-note { margin-top: 0.4rem; font-size: 0.8rem; opacity: 0.7; max-width: 90%; }

/* ------------------------------------------------------------
   Theme Toggle (päike/kuu nupp)
------------------------------------------------------------ */
.theme-toggle {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 999;
  background: rgba(255,255,255,0.08);
  color: var(--accent);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 50%;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  cursor: pointer;
  transition: all 0.25s ease;
  box-shadow: inset 0 0 10px rgba(255,255,255,0.1);
}
.theme-toggle:hover {
  background: rgba(255,255,255,0.25);
  transform: scale(1.1) rotate(8deg);
}

/* ------------------------------------------------------------
   Light Mode
------------------------------------------------------------ */
body.light {
  background: #f8f9fc;
  color: #1b1e24;
}
body.light .aurora {
  filter: saturate(80%) brightness(1.25) contrast(1.05);
}
body.light section,
body.light .card {
  background: linear-gradient(135deg, rgba(255,255,255,0.9), rgba(255,255,255,0.75));
  border: 1px solid rgba(0,0,0,0.08);
  box-shadow: 0 12px 40px rgba(0,0,0,0.08), inset 0 1px 0 rgba(255,255,255,0.8);
  backdrop-filter: blur(18px) saturate(120%);
  color: #111;
}
body.light .subtitle { color: #4e5560; }
body.light p { color: #1f1f1f; }
body.light a { color: #0058a3; }
body.light a:hover { color: #0070d4; }

/* ------------------------------------------------------------
   Header Layout
------------------------------------------------------------ */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 998;
  background: transparent;
  pointer-events: none;
}
.header-inner {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  pointer-events: all;
}

/* ------------------------------------------------------------
   Responsive & Motion Preferences
------------------------------------------------------------ */
@media (max-width: 600px) {
  main { padding: 6vh 1rem 10vh; }
  section, .card { padding: 1.4rem 1rem 1.6rem; }
  h1 { font-size: 1.7rem; }
  .subtitle { font-size: 1rem; }
  p { font-size: 0.98rem; line-height: 1.6; }
  footer { font-size: 0.82rem; margin-top: 5vh; padding-bottom: 4vh; }
}

@media (prefers-reduced-motion: reduce) {
  .aurora, section::before, .card::before { animation: none !important; }
}

/* ------------------------------------------------------------
   Back-controls (2-line layout: Copyright & 404)
------------------------------------------------------------ */
.back-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 2.2rem;
  font-size: 0.95rem;
  color: var(--muted);
}

.back-controls a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  font-size: 1rem;
}

.back-controls a:hover {
  text-decoration: underline;
}

/* Second line layout */
.return-line {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.return-line .timer {
  opacity: 0.8;
  font-size: 0.88rem;
}

.return-line button {
  background: rgba(255,255,255,0.1);
  color: var(--fg);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 10px;
  padding: 0.35rem 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.9rem;
}

.return-line button:hover {
  background: rgba(255,255,255,0.2);
  transform: scale(1.05);
}

/* === WCAG Fix: Footer contrast in Light Mode === */
body.light footer {
  color: #1b1e24; /* stronger readable base text */
  background: linear-gradient(135deg, rgba(255,255,255,0.75), rgba(255,255,255,0.55));
  border-top: 1px solid rgba(0,0,0,0.05);
}

body.light footer a,
body.light footer a:visited {
  color: #0058a3; /* consistent with link color */
}

body.light footer a:hover,
body.light footer a:focus-visible {
  color: #0070d4; /* slightly brighter blue on hover for contrast */
  text-decoration: underline;
}
