/*
Theme Name: Cody
Theme URI: https://example.com/cody
Author: Henning
Author URI: https://example.com
Description: Ein leeres WordPress-Starter-Theme.
Version: 1.0.5
Requires at least: 6.0
Tested up to: 6.5
Requires PHP: 7.4
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: cody
*/

/* =========================================================
   1. Custom Properties (Design-Tokens)
   ========================================================= */
:root {
	--cody-color-text: #1a1a1a;
	--cody-color-bg: #ffffff;
	--cody-color-accent: #2563eb;
	--cody-color-muted: #6b7280;
	--cody-color-border: #e5e7eb;
	--cody-color-bg2: #e4e4e4;

	--cody-font-base: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	--cody-font-size: 1rem;
	--cody-font-weight: 400;
	--cody-line-height: 1.6;

	--cody-content-width: 70rem;
	--cody-space: 16px;
}

/* =========================================================
   2. Reset / Basis
   ========================================================= */
*,
*::before,
*::after {
	box-sizing: border-box;
}

body {
	margin: 0;
	font-family: var(--cody-font-base);
	font-size: var(--cody-font-size);
	font-weight: var(--cody-font-weight);
	line-height: var(--cody-line-height);
	color: var(--cody-color-text);
	background: var(--cody-color-bg);
}

img,
picture,
video,
svg {
	max-width: 100%;
	height: auto;
	display: block;
}

a {
	color: var(--cody-color-accent);
	text-decoration: none;
}

a:hover,
a:focus {
	text-decoration: none;
}

h1, h2, h3, h4, h5, h6 {
	line-height: 1.2;
	margin: 0 0 0.5em;
}

p {
	margin: 0 0 1em;
}

/* =========================================================
   3. Barrierefreiheit (Helfer)
   ========================================================= */

/* Sichtbarer Fokus für alle interaktiven Elemente. */
:where(a, button, input, select, textarea, summary):focus-visible {
	outline: 2px solid var(--cody-color-accent);
	outline-offset: 2px;
}

/* Inhalt nur für Screenreader (visuell versteckt). */
.screen-reader-text {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* Skip-Link: bei Tastaturfokus sichtbar einblenden. */
.skip-link {
	position: absolute;
	top: 0;
	left: 0;
	z-index: 1000;
	padding: var(--cody-space);
	background: var(--cody-color-bg);
	color: var(--cody-color-accent);
}

.skip-link:focus {
	clip: auto;
	width: auto;
	height: auto;
	margin: 0;
}

/* =========================================================
   4. Layout
   ========================================================= */
.site-header__inner,
.site-content,
.site-footer {
	max-width: var(--cody-content-width);
	margin-inline: auto;
	padding-inline: var(--cody-space);
}

.site-header {
	background: var(--cody-color-bg2);
}

.site-header__inner {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: var(--cody-space);
	padding-block: var(--cody-space);
}


.site-title {
	font-size: 1.5rem;
	font-weight: 700;
	color: var(--cody-color-text);
}

.site-content {
	padding-block: calc(var(--cody-space) * 2);
	padding-block-end: 0;
}

.site-footer {
	padding-block: calc(var(--cody-space) * 2);
	color: var(--cody-color-muted);
}

/* =========================================================
   5. Navigation (mobile-first)
   ========================================================= */

/* Hamburger-Icon (drei Striche über ::before/::after). */
.nav-toggle {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 2.75rem;
	height: 2.75rem;
	padding: 0;
	background: transparent;
	border: 1px solid var(--cody-color-border);
	border-radius: 0.25rem;
	cursor: pointer;
}

.nav-toggle__icon,
.nav-toggle__icon::before,
.nav-toggle__icon::after {
	display: block;
	width: 1.25rem;
	height: 2px;
	background: var(--cody-color-text);
}

.nav-toggle__icon {
	position: relative;
}

.nav-toggle__icon::before,
.nav-toggle__icon::after {
	content: "";
	position: absolute;
	left: 0;
}


.nav-toggle__icon::before {
	top: -6px;
}

.nav-toggle__icon::after {
	top: 6px;
}

/* Menü auf Mobile standardmäßig ausgeblendet. */
.nav-menu {
	display: none;
	flex-direction: column;
	gap: 0.25rem;
	width: 100%;
	margin: var(--cody-space) 0 0;
	padding: 0;
	list-style: none;
}

/* Von JS gesetzt, wenn der Toggle aktiv ist. */
.site-navigation.is-open .nav-menu {
	display: flex;
}

.nav-menu a {
	display: block;
	padding: 0.5rem 0;
	color: var(--cody-color-text);
}

.nav-menu a:hover,
.nav-menu a:focus {
	color: var(--cody-color-accent);
}

/* Ab Tablet/Desktop: horizontale Leiste, Toggle ausblenden. */
@media (min-width: 53.125em) { /* 850px */
	.nav-toggle {
		display: none;
	}

	.nav-menu {
		display: flex;
		flex-direction: row;
		flex-wrap: wrap;
		gap: var(--cody-space);
		width: auto;
		margin: 0;
	}

	.nav-menu a {
		padding: 0;
	}
}

/* =========================================================
   6. Beiträge
   ========================================================= */
article {
	margin-bottom: calc(var(--cody-space) * 2);
	padding-bottom: calc(var(--cody-space) * 2);
	border-bottom: 1px solid var(--cody-color-border);
}

article:last-child {
	border-bottom: 0;
}

.entry-title {
	font-size: 1.75rem;
}

/* =========================================================
   7. Raster (12-Spalten-Grid)
   =========================================================
   Im Block-Editor nutzbar: einem Spalten-Block (oder einer Gruppe) die Klasse
   .cody-grid geben, den einzelnen Spalten .cody-col-1 … .cody-col-12 (Summe der
   Spannweiten = 12). display:grid überschreibt das Flex-Layout des Columns-Blocks
   und rechnet die Gaps korrekt heraus – anders als flex-basis % + gap, das zu
   ungleichen Spaltenbreiten führt. Die Spalten nehmen beliebige Blöcke auf.
   ========================================================= */
.cody-grid {
	display: grid;
	grid-template-columns: 1fr; /* mobil: eine Spalte (gestapelt) */
	gap: var(--cody-space);
}

/* Group-Block-Wrapper mancher WP-Versionen flach machen,
   damit die Spalten direkte Grid-Items werden. */
.cody-grid > .wp-block-group__inner-container {
	display: contents;
}

/* Spalten dürfen schmaler als ihr Inhalt werden – sonst sprengen z. B. Bilder
   oder lange Wörter die Spaltenbreite (grid blowout). So lässt sich beliebiger
   Block-Editor-Inhalt (Bilder, Buttons, Überschriften …) in jede Spalte packen. */
[class*="cody-col-"] {
	min-width: 0;
}

@media (min-width: 53.125em) { /* 850px */
	.cody-grid {
		grid-template-columns: repeat(12, 1fr);
	}

	.cody-col-1  { grid-column: span 1; }
	.cody-col-2  { grid-column: span 2; }
	.cody-col-3  { grid-column: span 3; }
	.cody-col-4  { grid-column: span 4; }
	.cody-col-5  { grid-column: span 5; }
	.cody-col-6  { grid-column: span 6; }
	.cody-col-7  { grid-column: span 7; }
	.cody-col-8  { grid-column: span 8; }
	.cody-col-9  { grid-column: span 9; }
	.cody-col-10 { grid-column: span 10; }
	.cody-col-11 { grid-column: span 11; }
	.cody-col-12 { grid-column: span 12; }
}

/* Zwischenschritt Tablet (850px – 1100px): Raster aus genau 4 gleichen
   Spalten (Pattern „4 gleiche Spalten", 4 × .cody-col-3) laufen 2×2,
   statt extrem schmal zu werden. Die Mengen-Abfrage (:first-child +
   :nth-last-child(4)) greift nur bei genau 4 Kindern, Misch-Layouts
   wie 3 + 9 bleiben unberührt. */
@media (min-width: 53.125em) and (max-width: 68.6875em) {
	.cody-grid > .cody-col-3:first-child:nth-last-child(4),
	.cody-grid > .cody-col-3:first-child:nth-last-child(4) ~ .cody-col-3 {
		grid-column: span 6;
	}
}

/* =========================================================
   8. Accordion / FAQ (.cody-accordion)
   =========================================================
   Nutzt native <details>/<summary> (Core-„Details"-Block, WP 6.3+):
   barrierefrei und ganz ohne JavaScript.
   ========================================================= */


.cody-accordion__item summary {
	display: flex;
	align-items: start;
	justify-content: space-between;
	gap: var(--cody-space);
	padding-block: 10px;
	list-style: none;            /* Standard-Dreieck entfernen (Firefox/Chrome) */
	cursor: pointer;
	font-size: 16px;
	font-weight: 700;
	color: var(--cody-color-text);
}

.cody-accordion__item summary::-webkit-details-marker {
	display: none;               /* Standard-Dreieck (Safari/altes Chrome) */
}

/* Box mit Chevron rechts (geschlossen: Chevron nach unten). */
.cody-accordion__item summary::after {
	content: "";
	flex: 0 0 auto;
	width: 2rem;
	height: 2rem;
	border: 1px solid currentColor;
	background: center / 0.75rem no-repeat
		url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12'%3E%3Cpath d='M1 4l5 5 5-5' fill='none' stroke='%231a1a1a' stroke-width='2'/%3E%3C/svg%3E");
}

/* Geöffnet: grüne Box, weißer Chevron nach oben. */
.cody-accordion__item[open] summary::after {
	border-color: var(--cody-color-accent);
	background-color: var(--cody-color-accent);
	background-image:
		url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12'%3E%3Cpath d='M1 8l5-5 5 5' fill='none' stroke='%23ffffff' stroke-width='2'/%3E%3C/svg%3E");
}

/* Antwort-Inhalt unter der Frage. */
.cody-accordion__item > :not(summary) {
	margin-block: 0 var(--cody-space);
}

/* Hier kommen deine eigenen Styles hin. */
