/* templatestyle.css – modèle AVEG de TNG (dossier template40) au design de www.aveg.ch.
   Couleurs, en-tête, menu et pied de page repris de css/base.css et css/layout.css du site.
   Les règles de TNG (genstyle.css) sont surchargées ici ; mytngstyle.css reste libre. */

/* ---------- Couleurs (base.css du site) ---------- */
:root {
  --ink: #1E2B33;
  --muted: #5F6B73;
  --bg: #F5F6F4;
  --surface: #FFFFFF;
  --rule: #D6DBD8;
  --accent: #B3202A;          /* rouge du drapeau valaisan */
  --accent-ink: #FFFFFF;
  --member: #2F5A45;
  --member-bg: #E4EFE8;
  --serif: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius: 6px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #E6EAEC; --muted: #A3AEB4; --bg: #151B1F; --surface: #1D252A; --rule: #34404A;
    --accent: #E0505A; --accent-ink: #151B1F; --member: #8FCBA9; --member-bg: #1F3329;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ink: #E6EAEC; --muted: #A3AEB4; --bg: #151B1F; --surface: #1D252A; --rule: #34404A;
  --accent: #E0505A; --accent-ink: #151B1F; --member: #8FCBA9; --member-bg: #1F3329;
  color-scheme: dark;
}

/* ---------- Page ---------- */
body, body.publicback, .publicback {
  margin: 0; background: var(--bg); background-image: none; color: var(--ink);
  font: 1rem/1.55 var(--sans);
}
body.aveg *, body.aveg *::before, body.aveg *::after { box-sizing: border-box; }
body.aveg [hidden] { display: none !important; }
body.aveg :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
body.aveg td, body.aveg th, body.aveg p, body.aveg li, body.aveg .normal { font-family: var(--sans); color: inherit; }
body.aveg a, body.aveg a:link, body.aveg a:active, body.aveg a:visited, body.aveg div.icons a { color: var(--accent); text-underline-offset: 3px; }
body.aveg h1, body.aveg h2, body.aveg h3 { font-family: var(--serif); font-weight: 600; line-height: 1.2; }
body.aveg img { max-width: 100%; height: auto; }

.wrap { width: min(100% - 2rem, 72rem); margin-inline: auto; }
.tng-contenu { display: block; min-height: 50vh; padding-top: 1.5rem; overflow-x: auto; }

/* ---------- En-tête (layout.css du site) ---------- */
.site-header { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: .75rem 1rem; padding-top: 1.25rem; }
.site-header .brand { display: flex; align-items: center; gap: .85rem; color: var(--ink) !important; text-decoration: none; }
.site-header .logo { height: 3.25rem; width: auto; flex: none; }
.site-header .brand-text { font: 700 1.25rem/1 var(--serif); letter-spacing: .02em; }
.site-header .brand-text span { display: block; margin-top: .3rem; font: 400 .8rem/1.3 var(--sans); color: var(--muted); letter-spacing: 0; }
.site-header .account { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; font-size: .9rem; }
.site-header .who { color: var(--member); }
.site-header a.join-btn, a.as-button { display: inline-flex; align-items: center; text-decoration: none; }
.primary, .secondary { border-radius: var(--radius); padding: 0 1.25rem; min-height: 2.75rem; font-weight: 600; }
a.primary, a.primary:link, a.primary:visited, .primary { background: var(--accent); color: var(--accent-ink) !important; border: 0; }
a.secondary, .secondary { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.site-header .join-btn { min-height: 2.25rem; padding: 0 1rem; font-size: .9rem; }
.join-actions { display: flex; flex-wrap: wrap; gap: .75rem; }

.theme-btn { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 2.25rem; height: 2.25rem; padding: 0;
             border: 1px solid var(--rule); border-radius: 50%; background: var(--surface); color: var(--ink); cursor: pointer;
             transition: background .15s ease, color .15s ease, border-color .15s ease; }
.theme-btn:hover, .theme-btn:focus-visible { border-color: var(--accent); background: var(--accent); color: var(--accent-ink); }
.theme-btn svg { width: 1.1rem; height: 1.1rem; }
.theme-btn .soleil { display: none; }
:root[data-theme="dark"] .theme-btn .soleil { display: block; }
:root[data-theme="dark"] .theme-btn .lune { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-btn .soleil { display: block; }
  :root:not([data-theme="light"]) .theme-btn .lune { display: none; }
}

/* Menu sommital */
.site-menu { grid-column: 1 / -1; border-block: 1px solid var(--rule); }
.site-menu ul { display: flex; flex-wrap: wrap; gap: 0 1.75rem; list-style: none; margin: 0; padding: 0; }
body.aveg .site-menu a, body.aveg .site-menu a:link, body.aveg .site-menu a:visited { display: block; padding: .7rem 0; color: var(--ink); text-decoration: none; font-weight: 500; border-bottom: 3px solid transparent; }
body.aveg .site-menu a:hover { color: var(--accent); }
body.aveg .site-menu a[aria-current="page"] { border-bottom-color: var(--accent); }
.menu-toggle { display: none; }

/* Menu de TNG, réservé aux administrateurs */
.tng-menu-admin { margin-top: .75rem; background: var(--surface); border: 1px solid var(--rule); border-left: 4px solid var(--member); border-radius: var(--radius); font-size: .9rem; }
.tng-menu-admin summary { cursor: pointer; padding: .55rem .9rem; font-weight: 600; color: var(--member); }
.tng-menu-admin summary span { font-weight: 400; color: var(--muted); }
body.aveg .tng-menu-admin a { color: var(--ink); }
body.aveg .tng-menu-admin a:hover { color: var(--accent); }
.tng-menu-admin ul { display: flex; flex-wrap: wrap; gap: .3rem 1.25rem; list-style: none; margin: 0; padding: 0 .9rem .75rem; }

@media (max-width: 40rem) {
  .site-header { grid-template-columns: 1fr; }
  .site-header .logo { height: 2.5rem; }
  .menu-toggle { display: block; width: 100%; text-align: left; background: none; border: 0; padding: .7rem 0; color: var(--ink); font: 600 1rem var(--sans); cursor: pointer; }
  .menu-toggle::after { content: "+"; float: right; }
  .menu-toggle[aria-expanded="true"]::after { content: "–"; }
  .site-menu ul { display: none; flex-direction: column; padding-bottom: .5rem; }
  .site-menu.open ul { display: flex; }
  .site-menu a { padding: .55rem 0; border-bottom: 0; }
  body.aveg .site-menu a[aria-current="page"] { color: var(--accent); }
}

/* Pied de page */
.site-footer { border-top: 1px solid var(--rule); margin-top: 3rem; padding: 1.5rem 0 1rem;
               display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; color: var(--muted); font-size: .85rem; }
.site-footer p { margin: 0; }
.site-footer ul { display: flex; flex-wrap: wrap; gap: .25rem 1.25rem; list-style: none; margin: 0; padding: 0; }
body.aveg .site-footer a, body.aveg .site-footer a:link, body.aveg .site-footer a:visited { color: var(--muted); }
body.aveg .site-footer a:hover { color: var(--accent); }
.footer, .tng-credit { font-size: .75rem; color: var(--muted); padding-bottom: 2rem; }
body.aveg a.footer:link, body.aveg a.footer:visited, body.aveg .tng-credit a { color: var(--muted); }
a.footer:hover { color: var(--accent); }

/* ---------- Menus de TNG masqués aux membres et aux visiteurs ---------- */
body.tng-membre .menucontainer,
body.tng-membre div.icons,
body.tng-membre ul.tngdd,
body.tng-membre #mast,
body.tng-membre .mhead,
body.tng-membre .menuback { display: none !important; }

/* Documents, Histoires, Audio, Albums, Notes : retirés de tous les menus, administrateurs compris */
ul.tngdd li:has(> a[href*="mediatypeID=documents"]),
ul.tngdd li:has(> a[href*="mediatypeID=histories"]),
ul.tngdd li:has(> a[href*="mediatypeID=recordings"]),
ul.tngdd li:has(> a[href*="browsealbums.php"]),
ul.tngdd li:has(> a[href*="browsenotes.php"]),
.mhead li:has(> a[href*="mediatypeID=documents"]),
.mhead li:has(> a[href*="mediatypeID=histories"]),
.mhead li:has(> a[href*="mediatypeID=recordings"]),
.mhead li:has(> a[href*="browsealbums.php"]),
.mhead li:has(> a[href*="browsenotes.php"]) { display: none !important; }

/* ---------- Contenus de TNG ---------- */
.header, .plainheader { color: var(--ink); font-family: var(--serif); font-weight: 600; }
h1.header, .header { font-size: clamp(1.5rem, 3.5vw, 2rem); }
.subhead, .subhead strong { font-family: var(--serif); color: var(--ink); }
.normal, .smaller { color: var(--ink); }
.smaller { font-size: .85rem; }

/* Cellules de libellés et de données */
.LB_closeAjaxWindow, .bar, .sideback, .fieldnameback, .tablesaw-cell-label { background-color: var(--member-bg); background-image: none; }
.fieldnameback, .fieldnameback .fieldname, .fieldnameback a, .fieldname, .tablesaw-cell-label { color: var(--member) !important; font-weight: 600; }
.databack, .reportcol li:hover, .fambackground { background-color: var(--surface); color: var(--ink); }
.databackalt { background-color: var(--bg); color: var(--ink); }
.whiteback, .titlebox { background-color: var(--surface); color: var(--ink); }
.titlebox { border: 1px solid var(--rule); border-radius: var(--radius); }
table.whiteback, .whiteback { border-color: var(--rule); }
.line { background: var(--rule); height: 1px; border: 0; }
.page, .indexpage { background: transparent; }

/* Onglets d'une fiche (Individu, Ancêtres, Descendants…) */
#tngnav, ul#tngnav { margin: 0 0 0 0; }
#tngnav a, #tngnav a:link, #tngnav a:visited, #tabs a {
  font: 500 .9rem/1.2 var(--sans); color: var(--ink); background: var(--surface);
  border: 1px solid var(--rule); border-bottom: 0; border-radius: var(--radius) var(--radius) 0 0; padding: .5em 1em .45em; text-decoration: none;
}
#tngnav a:hover, #tabs a:hover { color: var(--accent); background: var(--surface); }
#tngnav a.here, #tabs .here { background: var(--accent); color: var(--accent-ink) !important; border-color: var(--accent); }

/* Champs et boutons des formulaires de TNG (sans toucher aux cases à cocher) */
body.aveg input[type="text"], body.aveg input[type="search"], body.aveg input[type="email"], body.aveg input[type="password"],
body.aveg input[type="number"], body.aveg input:not([type]), body.aveg select, body.aveg textarea {
  font: inherit; font-size: .95rem; color: var(--ink); background: var(--surface);
  border: 1px solid var(--rule); border-radius: var(--radius); padding: .35rem .55rem; min-height: 2.25rem; max-width: 100%;
}
body.aveg input[type="submit"], body.aveg input[type="button"], body.aveg button.btn, body.aveg .btn {
  font: 600 .95rem var(--sans); background: var(--accent); color: var(--accent-ink); border: 0;
  border-radius: var(--radius); padding: .5rem 1.1rem; min-height: 2.25rem; cursor: pointer;
}
body.aveg input[type="submit"]:hover, body.aveg input[type="button"]:hover { filter: brightness(1.08); }

/* Fenêtres et menus déroulants de TNG (administrateurs) */
.LB_window { background: var(--surface); border: 1px solid var(--rule); color: var(--ink); border-radius: var(--radius); }
div.innercontainer { border-bottom: 1px solid var(--rule); background: var(--surface); background-image: none; }
ul.tngdd { background-color: var(--surface); }
ul.tngdd a { color: var(--accent); }
ul.tngdd .menulink, ul.tngdd .langmenu, ul.tngdd .stubmenu { background: var(--surface); background-image: none; border-color: var(--rule); color: var(--ink); }
ul.tngdd .menulink:hover, ul.tngdd .menuhover { background: var(--accent); background-image: none; color: var(--accent-ink); border-color: var(--accent); }
ul.tngdd ul li a, .slidedown { background-color: var(--surface); }
ul.tngdd ul li a:hover { background-color: var(--bg); }
.snlink { border: 1px solid var(--rule); background-color: var(--surface); color: var(--ink); }
a.snlink:hover, .snlinkact, .adminnav .snlinkact { background-color: var(--accent); color: var(--accent-ink); }
a.admincell:hover, a.leftlink:hover { background-color: var(--member-bg); }
.mmaintitle { font-family: var(--serif); color: var(--accent); opacity: .5; }

/* Thème sombre : les cases que TNG colore lui-même (graphiques, arbres) gardent un texte foncé */
:root[data-theme="dark"] body.aveg [bgcolor],
:root[data-theme="dark"] body.aveg [style*="background-color"],
:root[data-theme="dark"] body.aveg [style*="background:"] { color: #1E2B33; }
:root[data-theme="dark"] body.aveg [bgcolor] a,
:root[data-theme="dark"] body.aveg [style*="background-color"] a,
:root[data-theme="dark"] body.aveg [style*="background:"] a { color: #8E1A22; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) body.aveg [bgcolor],
  :root:not([data-theme="light"]) body.aveg [style*="background-color"],
  :root:not([data-theme="light"]) body.aveg [style*="background:"] { color: #1E2B33; }
  :root:not([data-theme="light"]) body.aveg [bgcolor] a,
  :root:not([data-theme="light"]) body.aveg [style*="background-color"] a,
  :root:not([data-theme="light"]) body.aveg [style*="background:"] a { color: #8E1A22; }
}

/* ---------- Repris du modèle 4 d'origine ---------- */
.overflowauto { width: 87vw; }
@media only screen and (min-width:1280px) and (max-width:1550px) { .overflowauto { width: 85vw; } }
@media only screen and (max-width:1280px) { .overflowauto { width: 80vw; } }
@media only screen and (max-width:1024px) { .overflowauto { width: 78vw; } }
@media only screen and (max-width:768px) { .overflowauto { width: 67vw; } }
.margin-top { margin-top: 10px; }
.margin-bottom { margin-bottom: 10px; }
.imgright { float: right; }
.admin-banner h1 { font-family: var(--serif); }
