/* ============================================================
   Team Segra – stilmall
   Färger hämtade från prototypen (teamsegra.se) + loggans guld
   ============================================================ */
:root {
  --red: #DD183B;
  --red-dark: #CC1939;
  --gold: #C9A227;
  --gold-light: #E8C766;
  --ink: #0F172A;
  --text: #3A3A3A;
  --muted: #6B7280;
  --bg: #FFFFFF;
  --bg-soft: #FFF7F3;
  --bg-alt: #FFEDE6;
  --line: #E5E7EB;
  --card: #FFFFFF;
  --shadow: 0 6px 24px rgba(15, 23, 42, .08);
  --radius: 14px;
  --font-head: "Cinzel", "Georgia", serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  font-size: 16px;
}
img { max-width: 100%; display: block; }
a { color: var(--red); text-decoration: none; }
a:hover { color: var(--red-dark); }
h1, h2, h3, h4 { color: var(--ink); line-height: 1.25; margin: 0 0 .5em; }
h1 { font-family: var(--font-head); font-size: clamp(1.8rem, 4vw, 2.6rem); }
h2 { font-family: var(--font-head); font-size: clamp(1.4rem, 3vw, 1.9rem); }
h3 { font-size: 1.15rem; }
p { margin: 0 0 1em; }
.container { width: min(1200px, 100% - 32px); margin-inline: auto; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.hidden { display: none !important; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: var(--red);
  color: #fff;
  border-bottom: 3px solid var(--gold);
}
.site-header .container {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  min-height: 74px;
}
.brand { display: flex; align-items: center; gap: 12px; color: #fff; }
.brand img { width: 56px; height: 56px; border-radius: 50%; background: #fff; }
.brand span {
  white-space: nowrap;
  font-family: var(--font-head); font-weight: 700; letter-spacing: .06em;
  font-size: 1.25rem; color: var(--gold-light);
}
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav a {
  white-space: nowrap;
  color: #fff; padding: 8px 10px; border-radius: 8px; font-weight: 500; font-size: .95rem;
}
.nav a:hover, .nav a.active { background: rgba(0,0,0,.22); color: var(--gold-light); }
.nav-toggle {
  display: none; background: none; border: 1px solid rgba(255,255,255,.3); color: #fff;
  border-radius: 8px; padding: 8px 10px; font-size: 1.2rem; cursor: pointer;
}
@media (max-width: 1000px) {
  .nav-toggle { display: block; }
  .nav {
    display: none; position: absolute; left: 0; right: 0; top: 100%;
    background: var(--red); flex-direction: column; padding: 8px 16px 16px;
    border-bottom: 3px solid var(--gold);
  }
  .nav.open { display: flex; }
}

/* ---------- Nyhetsticker ---------- */
.ticker {
  background: var(--ink); color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.ticker .container { display: flex; align-items: center; gap: 14px; min-height: 48px; }
.ticker-label {
  font-weight: 700; letter-spacing: .08em; font-size: .75rem; text-transform: uppercase;
  background: var(--red); padding: 4px 10px; border-radius: 6px; white-space: nowrap;
}
.ticker-viewport { flex: 1; overflow: hidden; position: relative; height: 48px; }
.ticker-item {
  position: absolute; inset: 0; display: flex; align-items: center; gap: 10px;
  color: #fff; opacity: 0; transform: translateY(100%); transition: transform .5s ease, opacity .5s ease;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ticker-item.active { opacity: 1; transform: translateY(0); }
.ticker-item.leaving { opacity: 0; transform: translateY(-100%); }
.ticker-item strong { font-weight: 700; }
.ticker-item em { font-style: normal; opacity: .9; overflow: hidden; text-overflow: ellipsis; }
.ticker-item:hover { text-decoration: underline; color: #fff; }
.ticker-controls { display: flex; gap: 4px; }
.ticker-controls button {
  background: rgba(255,255,255,.12); border: 0; color: #fff; width: 30px; height: 30px; border-radius: 6px; cursor: pointer;
}
.ticker-controls button:hover { background: rgba(255,255,255,.25); }
@media (max-width: 600px) { .ticker-label { display: none; } }

/* ---------- Hero ---------- */
.hero {
  background: radial-gradient(1200px 500px at 20% -10%, #F04A66 0%, var(--red) 55%, #B3122F 100%);
  color: #fff; padding: 56px 0;
}
.hero .container { display: grid; grid-template-columns: 300px 1fr; gap: 48px; align-items: center; }
.hero img { width: 300px; height: 300px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 8px rgba(201,162,39,.55), 0 20px 50px rgba(0,0,0,.35); }
.hero h1 { color: #fff; }
.hero h1 span { color: var(--gold-light); }
.hero p { color: #FFE4E9; font-size: 1.05rem; max-width: 62ch; }
.hero .cta { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 20px; }
@media (max-width: 800px) {
  .hero .container { grid-template-columns: 1fr; text-align: center; }
  .hero img { margin-inline: auto; width: 220px; height: 220px; }
  .hero p { margin-inline: auto; }
  .hero .cta { justify-content: center; }
}

/* ---------- Knappar ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--red); color: #fff; border: 0; padding: 10px 18px; border-radius: 10px;
  font-weight: 600; cursor: pointer; font-size: .95rem; font-family: inherit;
  transition: background .15s, transform .1s;
}
.btn:hover { background: var(--red-dark); color: #fff; }
.btn:active { transform: translateY(1px); }
.btn.gold { background: var(--gold); color: var(--ink); }
.btn.gold:hover { background: var(--gold-light); }
.btn.ghost { background: transparent; border: 1px solid currentColor; color: var(--ink); }
.btn.ghost:hover { background: var(--bg-alt); }
.hero .btn.ghost { color: #fff; }
.hero .btn.ghost:hover { background: rgba(255,255,255,.1); }
.btn.danger { background: #B91C1C; }
.btn.sm { padding: 6px 12px; font-size: .85rem; }

/* ---------- Sektioner ---------- */
.section { padding: 56px 0; }
.section.alt { background: var(--bg-soft); }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.section-head h2 { margin: 0; }
.section-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.eyebrow { text-transform: uppercase; letter-spacing: .12em; font-size: .75rem; font-weight: 700; color: var(--red); margin-bottom: 6px; }

/* ---------- Deltagare ---------- */
.grid { display: grid; gap: 24px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.athlete-card {
  background: var(--card); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
  transition: transform .15s, box-shadow .15s; color: inherit; display: flex; flex-direction: column;
}
.athlete-card:hover { transform: translateY(-4px); box-shadow: 0 12px 32px rgba(15,23,42,.14); color: inherit; }
.athlete-card .photo { aspect-ratio: 1 / 1; overflow: hidden; background: #f3f4f6; }
.athlete-card .photo img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.athlete-card .body { padding: 14px 16px 16px; }
.athlete-card h3 { margin: 0 0 2px; }
.athlete-card .sport { color: var(--red); font-weight: 600; font-size: .9rem; }
.athlete-card .club { color: var(--muted); font-size: .85rem; }

.profile { display: grid; grid-template-columns: 380px 1fr; gap: 40px; align-items: start; }
.profile .photo img { border-radius: var(--radius); box-shadow: var(--shadow); width: 100%; }
.profile dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0 0 20px; }
.profile dt { font-weight: 700; color: var(--ink); }
.profile dd { margin: 0; }
.profile .facts h3 { margin-top: 20px; }
.profile ul { padding-left: 20px; }
.social { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
@media (max-width: 800px) { .profile { grid-template-columns: 1fr; } }
.badge { display: inline-block; background: var(--bg-alt); color: var(--red-dark); padding: 2px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600; }

/* ---------- Nyheter ---------- */
.news-list { display: grid; gap: 20px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.news-card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px;
  color: inherit; display: flex; flex-direction: column; gap: 8px; border-top: 4px solid var(--gold);
}
.news-card:hover { color: inherit; box-shadow: 0 12px 32px rgba(15,23,42,.14); }
.news-card time { font-size: .8rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.news-card h3 { margin: 0; }
.news-card p { margin: 0; color: var(--text); }
.news-card .more { margin-top: auto; color: var(--red); font-weight: 600; font-size: .9rem; }
.news-card .thumb { border-radius: 8px; aspect-ratio: 16/9; object-fit: cover; width: 100%; }
.article { max-width: 760px; }
.article time { color: var(--muted); font-weight: 600; }
.article .lead { font-size: 1.15rem; color: var(--ink); }
.article .body { white-space: pre-line; }
.article img.cover { border-radius: var(--radius); margin: 20px 0; }
.article-actions { display: flex; gap: 8px; margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--line); }

/* ---------- Kalender ---------- */
.cal-layout { display: grid; grid-template-columns: 1fr 340px; gap: 32px; align-items: start; }
@media (max-width: 900px) { .cal-layout { grid-template-columns: 1fr; } }
.cal-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.cal-toolbar h3 { margin: 0; font-family: var(--font-head); font-size: 1.3rem; text-transform: capitalize; }
.cal-toolbar .nav-btns { display: flex; gap: 6px; }
.cal-toolbar .nav-btns button {
  background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; cursor: pointer; font-family: inherit;
}
.cal-toolbar .nav-btns button:hover { background: var(--bg-alt); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-dow { text-align: center; font-size: .75rem; font-weight: 700; color: var(--muted); text-transform: uppercase; padding: 6px 0; }
.cal-day {
  background: #fff; border: 1px solid var(--line); border-radius: 8px; min-height: 92px; padding: 6px; cursor: pointer;
  display: flex; flex-direction: column; gap: 3px; transition: border-color .15s;
}
.cal-day:hover { border-color: var(--gold); }
.cal-day.other { background: #FAFAFA; color: #C4C4C4; }
.cal-day.today { border-color: var(--red); box-shadow: inset 0 0 0 1px var(--red); }
.cal-day .num { font-size: .8rem; font-weight: 700; }
.cal-day.today .num { color: var(--red); }
.cal-ev {
  font-size: .72rem; padding: 2px 6px; border-radius: 4px; background: var(--bg-alt); color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-left: 3px solid var(--gold);
}
.cal-ev.tavling { background: #FDE2E7; border-left-color: var(--red); }
.cal-more { font-size: .7rem; color: var(--muted); }
@media (max-width: 600px) {
  .cal-day { min-height: 56px; padding: 4px; }
  .cal-ev { font-size: 0; height: 6px; padding: 0; border-left: 0; border-radius: 3px; background: var(--gold); }
  .cal-ev.tavling { background: var(--red); }
}
.event-list { display: flex; flex-direction: column; gap: 10px; }
.event-item {
  display: grid; grid-template-columns: 56px 1fr; gap: 12px; background: #fff; border-radius: 10px;
  padding: 10px 12px; box-shadow: var(--shadow); cursor: pointer; border-left: 4px solid var(--gold);
}
.event-item.tavling { border-left-color: var(--red); }
.event-item:hover { box-shadow: 0 10px 28px rgba(15,23,42,.14); }
.event-item .date { text-align: center; line-height: 1.1; }
.event-item .date .d { font-size: 1.4rem; font-weight: 800; color: var(--ink); }
.event-item .date .m { font-size: .7rem; text-transform: uppercase; font-weight: 700; color: var(--red); }
.event-item h4 { margin: 0 0 2px; font-size: 1rem; }
.event-item .meta { font-size: .8rem; color: var(--muted); }
.legend { display: flex; gap: 14px; font-size: .8rem; color: var(--muted); margin-top: 10px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: middle; }
.side-card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 20px; }
.side-card h3 { margin-top: 0; }
.empty { color: var(--muted); font-style: italic; padding: 10px 0; }

/* ---------- Tabell ---------- */
table { width: 100%; border-collapse: collapse; background: #fff; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
th, td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--line); }
th { background: var(--ink); color: #fff; font-weight: 600; font-size: .85rem; letter-spacing: .04em; text-transform: uppercase; }
tr:last-child td { border-bottom: 0; }
td.num { text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.medal { display: inline-block; width: 22px; height: 22px; border-radius: 50%; line-height: 22px; text-align: center; font-size: .75rem; font-weight: 700; color: #fff; }
.medal.g { background: #D4AF37; } .medal.s { background: #A8A9AD; } .medal.b { background: #CD7F32; }
.row-actions button { background: none; border: 0; cursor: pointer; color: var(--muted); font-size: 1rem; }
.row-actions button:hover { color: var(--red); }

/* ---------- Om oss ---------- */
.about { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; align-items: center; }
.about img { border-radius: var(--radius); box-shadow: var(--shadow); }
@media (max-width: 800px) { .about { grid-template-columns: 1fr; } }
.values { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; margin-top: 32px; }
.value { background: #fff; padding: 20px; border-radius: var(--radius); box-shadow: var(--shadow); border-top: 4px solid var(--red); }
.value h3 { margin-top: 0; }

/* ---------- Modal / formulär ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15,23,42,.55); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 16px;
  animation: fade .15s ease;
}
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
.modal {
  background: #fff; border-radius: 16px; width: min(640px, 100%); max-height: 90vh; overflow: auto;
  box-shadow: 0 30px 80px rgba(0,0,0,.4);
}
.modal header { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal header h3 { margin: 0; }
.modal header button { background: none; border: 0; font-size: 1.4rem; cursor: pointer; color: var(--muted); }
.modal .content { padding: 22px; }
.modal footer { display: flex; justify-content: space-between; gap: 8px; padding: 16px 22px; border-top: 1px solid var(--line); background: #FAFAFA; }
.modal footer .right { display: flex; gap: 8px; margin-left: auto; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } }
label { display: block; font-weight: 600; font-size: .85rem; margin-bottom: 4px; color: var(--ink); }
input, select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid #D1D5DB; border-radius: 8px; font-family: inherit; font-size: .95rem;
  background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--gold-light); border-color: var(--gold); }
textarea { min-height: 110px; resize: vertical; }
.help { font-size: .78rem; color: var(--muted); margin-top: 3px; }
.event-detail dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; }
.event-detail dt { font-weight: 700; color: var(--ink); }
.event-detail dd { margin: 0; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 10px; z-index: 200;
  box-shadow: 0 10px 30px rgba(0,0,0,.3); animation: fade .2s;
}

/* ---------- Footer ---------- */
.site-footer { background: var(--red); color: #FFE4E9; padding: 40px 0 24px; margin-top: 40px; border-top: 4px solid var(--gold); }
.site-footer .container { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 32px; }
.site-footer h4 { color: var(--gold-light); font-family: var(--font-head); }
.site-footer a { color: #fff; }
.site-footer a:hover { color: var(--gold-light); }
.site-footer ul { list-style: none; padding: 0; margin: 0; }
.site-footer li { margin-bottom: 6px; }
.site-footer .copy { grid-column: 1 / -1; border-top: 1px solid rgba(255,255,255,.25); padding-top: 16px; font-size: .85rem; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
.site-footer .copy button { background: none; border: 0; color: #FFD1BF; cursor: pointer; font-size: .85rem; text-decoration: underline; font-family: inherit; }
@media (max-width: 700px) { .site-footer .container { grid-template-columns: 1fr; } }

/* ---------- Breadcrumb ---------- */
.crumb { font-size: .85rem; color: var(--muted); margin-bottom: 14px; }
.crumb a { color: var(--muted); }
.crumb a:hover { color: var(--red); }

/* ---------- Inloggning ---------- */
.auth-btn {
  background: rgba(0,0,0,.22); border: 1px solid rgba(255,255,255,.35); color: #fff;
  padding: 7px 12px; border-radius: 8px; font-family: inherit; font-size: .85rem; font-weight: 600; cursor: pointer;
  margin-left: 8px;
}
.auth-btn:hover { background: var(--gold); color: var(--ink); border-color: var(--gold); }
body.logged-in .auth-btn { background: var(--gold); color: var(--ink); border-color: var(--gold); }
body.logged-in .auth-btn::before { content: "● "; color: #16A34A; }
@media (max-width: 1000px) { .auth-btn { margin: 8px 0 0; align-self: flex-start; } }
/* Låsikon på redigeringsknappar när man inte är inloggad */
body:not(.logged-in) #add-news::before,
body:not(.logged-in) #add-event::before,
body:not(.logged-in) #add-result::before,
body:not(.logged-in) #edit-news::before { content: "🔒 "; }

/* ---------- Redigera deltagare ---------- */
.athlete-wrap { display: flex; flex-direction: column; }
.athlete-wrap .athlete-card { flex: 1; }
.admin-tools { display: none; justify-content: space-between; gap: 4px; margin-top: 6px; }
body.logged-in .admin-tools { display: flex; }
.admin-tools button {
  background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 4px 10px; cursor: pointer;
  font-family: inherit; font-size: .8rem; color: var(--ink);
}
.admin-tools button:hover { border-color: var(--gold); background: var(--bg-soft); }
.admin-only { display: none; }
body.logged-in .admin-only { display: block; }
body:not(.logged-in) #add-participant::before,
body:not(.logged-in) #edit-participant::before { content: "🔒 "; }
.photo-pick { display: grid; grid-template-columns: 96px 1fr; gap: 14px; align-items: start; }
.photo-pick img { width: 96px; height: 96px; object-fit: cover; object-position: top; border-radius: 10px; background: #f3f4f6; border: 1px solid var(--line); }
input[type="file"] { padding: 6px; font-size: .85rem; }

/* ---------- Medaljer ---------- */
th.c { text-align: center; }
table.summary th { background: var(--red); }
table.summary tfoot th { background: var(--bg-alt); color: var(--ink); text-align: left; }
table.summary tfoot th.num { text-align: center; }
.medal-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.medal-chip { display: inline-flex; align-items: center; gap: 4px; background: var(--bg-soft); border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px 4px 12px; font-size: .85rem; }
.medal-chip strong { margin-right: 4px; }

/* Flerstycksberättelser på deltagarsidan (tomrad = nytt stycke) */
.bio { white-space: pre-line; margin: 0 0 1em; }

/* ---------- Kontaktformulär ---------- */
.contact-layout { display: grid; grid-template-columns: 1fr 1.15fr; gap: 48px; align-items: start; }
@media (max-width: 860px) { .contact-layout { grid-template-columns: 1fr; gap: 28px; } }
.contact-form { background: #fff; padding: 24px; border-radius: var(--radius); box-shadow: var(--shadow); border-top: 4px solid var(--gold); }
.form-error { background: #FDE2E7; color: #9F1239; border-left: 4px solid var(--red); padding: 10px 14px; border-radius: 8px; font-weight: 600; font-size: .9rem; }

/* ---------- Partners ---------- */
.partners-intro { max-width: 68ch; }
.partners-intro .lead { font-size: 1.1rem; color: var(--ink); }
.value-props { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 20px; margin-top: 32px; }
.value-props .value { border-top-color: var(--gold); }
.partner-list { display: grid; gap: 24px; margin-top: 20px; }
.partner-card {
  display: grid; grid-template-columns: 260px 1fr; gap: 28px; align-items: center;
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; border-left: 5px solid var(--red);
}
@media (max-width: 760px) { .partner-card { grid-template-columns: 1fr; gap: 16px; } }
.partner-logo {
  display: flex; align-items: center; justify-content: center;
  background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 18px; min-height: 150px;
}
.partner-logo:hover { border-color: var(--gold); }
.partner-logo img { max-height: 120px; width: auto; object-fit: contain; }
.partner-body h3 { margin: 6px 0 8px; font-family: var(--font-head); font-size: 1.35rem; }
.partner-why { background: var(--bg-soft); border-radius: 8px; padding: 10px 14px; font-size: .92rem; }
.partner-cta {
  margin-top: 48px; background: var(--ink); color: #fff; border-radius: var(--radius); padding: 32px;
  text-align: center; border-top: 4px solid var(--gold);
}
.partner-cta h2 { color: #fff; }
.partner-cta p { color: #D1D5DB; max-width: 60ch; margin-inline: auto; }

/* Extern-pil i sidfotens idrottslänkar */
.site-footer .ext { opacity: .6; font-size: .8em; }
.site-footer li a:hover .ext { opacity: 1; }

/* Visas bara för inloggad administratör */
.admin-only-inline { display: none; }
body.is-admin .admin-only-inline { display: inline; }
/* Skrivskyddat läge – ingen kontakt med servern */
body.read-only .auth-btn { opacity: .55; }
