/*
 * NORTIA base: reset, typography, layout shell, header, footer, buttons.
 * All values come from tokens.css.
 */

/* ---- Reset ------------------------------------------------------------ */

*,
*::before,
*::after {
	box-sizing: border-box;
}

html {
	-webkit-text-size-adjust: 100%;
	text-size-adjust: 100%;
}

body {
	position: relative; /* anchors the overlay header below the WP admin bar */
	margin: 0;
	min-height: 100svh;
	display: flex;
	flex-direction: column;
	background: var(--color-bg);
	color: var(--color-text);
	font-family: var(--font-body);
	font-size: var(--text-base);
	line-height: var(--leading-body);
	-webkit-font-smoothing: antialiased;
	overflow-x: clip;
}

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

input,
button,
textarea,
select {
	font: inherit;
	color: inherit;
}

h1,
h2,
h3,
h4,
p,
figure,
blockquote,
ul,
ol {
	margin-block: 0;
}

/* ---- Typography ------------------------------------------------------- */

h1,
h2,
h3,
h4 {
	font-family: var(--font-display);
	font-weight: 400;
	line-height: var(--leading-snug);
	letter-spacing: var(--tracking-display);
	text-wrap: balance;
}

h1 { font-size: var(--text-3xl); line-height: var(--leading-tight); }
h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-xl); }
h4 { font-size: var(--text-lg); }

p {
	text-wrap: pretty;
}

* + p {
	margin-block-start: var(--space-s);
}

a {
	color: inherit;
	text-decoration-thickness: 1px;
	text-underline-offset: 0.2em;
	transition: color var(--duration-fast) var(--ease-out);
}

a:hover {
	color: var(--color-accent);
}

/* ---- Accessibility ---------------------------------------------------- */

:focus-visible {
	outline: 2px solid var(--color-focus);
	outline-offset: 3px;
}

.screen-reader-text {
	position: absolute !important;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
}

.skip-link {
	position: absolute;
	inset-block-start: var(--space-2xs);
	inset-inline-start: var(--space-2xs);
	z-index: 100;
	padding: var(--space-2xs) var(--space-s);
	background: var(--color-text);
	color: var(--color-bg);
	transform: translateY(-200%);
}

.skip-link:focus {
	transform: none;
}

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

.container {
	width: 100%;
	max-width: var(--container-max);
	margin-inline: auto;
	/* The page uses viewport-fit=cover: in landscape, keep content clear of
	   a phone's notch and rounded corners. */
	padding-inline:
		max(var(--gutter), env(safe-area-inset-left, 0px))
		max(var(--gutter), env(safe-area-inset-right, 0px));
}

.site-main {
	flex: 1;
}

.section {
	padding-block: var(--space-xl);
}

.page-main {
	padding-block: var(--space-l) var(--space-2xl);
}

.page-header {
	margin-block-end: var(--space-l);
}

.page-content > * + * {
	margin-block-start: var(--space-s);
}

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

.site-header {
	border-block-end: var(--border-hairline);
	padding-block-start: env(safe-area-inset-top, 0px);
}

.site-header__inner {
	display: grid;
	grid-template-columns: auto 1fr auto;
	align-items: center;
	gap: var(--space-m);
	min-height: var(--header-height);
}

/* Front page: transparent header laid over the first screen of the hero.
   It scrolls away with the hero; no JS, no scroll listener. */
.site-header--overlay {
	position: absolute;
	inset-inline: 0;
	inset-block-start: 0;
	z-index: 10;
	border-block-end: 0;
	background: transparent;
	color: var(--color-hero-ink);
}

.site-header--overlay .site-logo__slot {
	border-color: currentColor;
}

/* The accent hover color is too dark on the hero; underline instead. */
.site-header--overlay a:hover {
	color: inherit;
	text-decoration: underline;
}

/* With hero.js running, the overlay header stays on screen over the hero
   (D34). At scroll 0 fixed and absolute sit in the same place, so the
   switch causes no jump. Top follows the WordPress admin bar. */
.site-header--overlay.is-pinned {
	position: fixed;
	inset-block-start: var(--wp-admin--admin-bar--height, 0px);
	border-block-end: 1px solid transparent;
}

/* Color changes animate only once hero.js has finished setting up
   (.is-ready), so nothing animates while the page opens. */
.site-header--overlay.is-pinned.is-ready {
	transition:
		background-color var(--duration-base) var(--ease-out),
		color var(--duration-base) var(--ease-out),
		border-color var(--duration-base) var(--ease-out);
}

/* The header's own color transition is enough: its links and logo inherit
   the color as it changes. Their own color transition (base "a" rule)
   would otherwise restart on every frame of the header's transition.
   The solid header keeps the links' hover fade. */
.site-header--overlay:not(.is-solid) a {
	transition: none;
}

/* Over the light part of the hero film (hero.js): dark ink, still transparent. */
.site-header--overlay.is-on-light {
	color: var(--color-text);
}

/* After the hero: solid ground in the approved background color. */
.site-header--overlay.is-solid {
	background: var(--color-bg);
	color: var(--color-text);
	border-block-end-color: var(--color-line);
}

.site-header--overlay.is-solid a:hover {
	color: var(--color-accent);
	text-decoration: none;
}

/* An opened mobile menu needs a solid ground to stay legible over the hero. */
.site-header--overlay.is-menu-open {
	background: var(--color-bg);
	color: var(--color-text);
}

/* Logo slot: empty until the approved logo is uploaded. Visible outline only,
   so nobody mistakes the gap for a finished design. No text or artwork. */
.site-logo {
	display: inline-flex;
	align-items: center;
	min-height: var(--tap-target);
}

.site-logo__slot {
	display: block;
	width: 7.5rem;
	height: 2rem;
	border: 1px dashed var(--color-text-muted);
}

.custom-logo {
	max-height: 2.5rem;
	width: auto;
}

.site-nav {
	justify-self: center;
}

.nav-list {
	display: flex;
	flex-wrap: wrap;
	gap: var(--space-2xs) var(--space-m);
	margin: 0;
	padding: 0;
	list-style: none;
}

.nav-list a,
.header-action {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: var(--tap-target);
	min-width: var(--tap-target);
	font-size: var(--text-sm);
	letter-spacing: var(--tracking-label);
	text-decoration: none;
}

.header-actions {
	grid-column: 3;
	justify-self: end;
	display: flex;
	gap: var(--space-m);
}

.nav-toggle {
	display: none;
	min-width: var(--tap-target);
	min-height: var(--tap-target);
	padding: 0 var(--space-xs);
	background: none;
	border: var(--border-hairline);
	border-radius: var(--radius-s);
	font-size: var(--text-sm);
	letter-spacing: var(--tracking-label);
	cursor: pointer;
}

/* Small screens: menu collapses behind the toggle, but only when JS runs.
   Without JS the list simply wraps below the header row. */
@media (max-width: 47.99rem) {
	.site-header__inner {
		grid-template-columns: auto 1fr auto;
		row-gap: 0;
	}

	/* Up to three header links ("Üye Ol", "Hesabım", "Sepet") must fit beside
	   the logo on a 360px phone without wrapping or horizontal scroll. */
	.site-header__inner {
		column-gap: var(--space-xs);
	}

	.header-actions {
		gap: var(--space-xs);
		white-space: nowrap;
	}

	.site-logo__slot {
		width: 6rem;
	}

	/* With a menu toggle in column 3, the actions move to column 2. */
	.js .nav-toggle ~ .header-actions {
		grid-column: 2;
	}

	.site-nav {
		grid-column: 1 / -1;
		justify-self: stretch;
	}

	.js .nav-toggle {
		display: inline-flex;
		align-items: center;
		grid-column: 3;
		grid-row: 1;
	}

	.js .site-nav:not(.is-open) {
		display: none;
	}

	.js .site-nav.is-open {
		padding-block: var(--space-s) var(--space-m);
	}

	.js .site-nav .nav-list {
		flex-direction: column;
	}
}

/* Very narrow phones (320-359px): three header links still fit on one row. */
@media (max-width: 22.4375rem) {
	.header-actions {
		gap: var(--space-2xs);
	}

	.header-action {
		letter-spacing: 0.02em;
	}

	.site-logo__slot {
		width: 5rem;
	}
}

/* ---- Buttons ---------------------------------------------------------- */

.button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: var(--space-2xs);
	min-height: var(--tap-target);
	padding: var(--space-xs) var(--space-m);
	border: 1px solid transparent;
	border-radius: var(--radius-s);
	font-size: var(--text-sm);
	letter-spacing: var(--tracking-label);
	text-decoration: none;
	cursor: pointer;
	transition:
		background-color var(--duration-fast) var(--ease-out),
		color var(--duration-fast) var(--ease-out),
		transform var(--duration-fast) var(--ease-out);
}

.button:active {
	transform: translateY(1px);
}

.button--primary {
	background: var(--color-accent);
	color: var(--color-on-accent);
}

.button--primary:hover {
	background: var(--color-text);
	color: var(--color-bg);
}

.button--secondary {
	border-color: var(--color-text);
	color: var(--color-text);
}

.button--secondary:hover {
	background: var(--color-text);
	color: var(--color-bg);
}

/* Quiet: text with a short hairline that extends on hover/focus,
   a discreet echo of the "trace in time" mark. Keeps the 44px tap height. */
.button--quiet {
	position: relative;
	padding-inline: 0;
	background: none;
	color: inherit;
}

.button--quiet::after {
	content: "";
	position: absolute;
	inset-inline: 0;
	inset-block-end: 0.55rem;
	height: 1px;
	background: currentColor;
	transform: scaleX(0.3);
	transform-origin: left center;
	transition: transform var(--duration-base) var(--ease-out);
}

.button--quiet:hover,
.button--quiet:focus-visible {
	color: inherit;
}

.button--quiet:hover::after,
.button--quiet:focus-visible::after {
	transform: scaleX(1);
}

.button-area {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--space-s) var(--space-m);
}

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

.site-footer {
	border-block-start: var(--border-hairline);
	padding-block: var(--space-l) calc(var(--space-l) + env(safe-area-inset-bottom, 0px));
	font-size: var(--text-sm);
	color: var(--color-text-muted);
}

.site-footer__inner {
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	align-items: flex-end;
	gap: var(--space-m);
}

.footer-nav {
	display: flex;
	flex-wrap: wrap;
	gap: var(--space-2xs) var(--space-m);
	margin: 0;
	padding: 0;
	list-style: none;
}

.footer-nav a {
	display: inline-flex;
	align-items: center;
	min-height: var(--tap-target);
}

/* A labelled link group, e.g. "Yasal" (menu location footer_legal). */
.footer-group__title {
	margin-block-end: var(--space-3xs);
	font-family: var(--font-body);
	font-size: var(--text-xs);
	font-weight: 600;
	line-height: var(--leading-snug);
	letter-spacing: var(--tracking-label);
	color: var(--color-text-muted);
}

.footer-nav--legal a {
	color: var(--color-text);
}

/* Phones: the legal links stack, each a full 44px row, easy to tap. */
@media (max-width: 29.99rem) {
	.footer-nav--legal {
		flex-direction: column;
		gap: 0;
	}
}

/* ---- Front page ------------------------------------------------------- */
/* Hero: hero.css. Collection section: collection.css (front page only). */

/* ---- Thread: "a trace left in time" (section headings) ---------------- */
/* A fine line with a small nail point at its start, above a section
   heading. It carries the hero's thread into the page: as the heading
   scrolls into view the line draws itself from left to right, and it
   shortens again when scrolling back. Used below the hero only.

   SWITCH: the line moves only on elements that also have the class
   "nortia-thread--draw" (see template-parts/collection.php). Remove that
   class and the line is simply shown in full, without motion.
   It is also shown in full, without motion, when the browser has no
   scroll-driven animations or the visitor prefers reduced motion. Only
   transform changes (no layout, no paint of other elements). */
.nortia-thread {
	--thread-length: min(100%, 7.5rem); /* phone */
	--thread-nail: 5px;
	position: relative;
	display: block;
	inline-size: var(--thread-length);
	block-size: var(--thread-nail);
	color: color-mix(in srgb, var(--color-text) 45%, transparent);
	view-timeline: --nortia-thread block;
}

/* The nail point: always visible, never moves. */
.nortia-thread::before {
	content: "";
	position: absolute;
	inset-inline-start: 0;
	inset-block-start: 0;
	inline-size: var(--thread-nail);
	block-size: var(--thread-nail);
	border-radius: 50%;
	background: currentColor;
}

/* The thread itself, from the nail to the right. */
.nortia-thread::after {
	content: "";
	position: absolute;
	inset-inline: calc(var(--thread-nail) + 4px) 0;
	inset-block-start: calc((var(--thread-nail) - 1px) / 2);
	block-size: 1px;
	background: currentColor;
	transform-origin: left center;
}

@keyframes nortia-thread-draw {
	from { transform: scaleX(0); }
	to   { transform: scaleX(1); }
}

@supports (animation-timeline: view()) {
	@media (prefers-reduced-motion: no-preference) {
		/* Phone: drawn while the heading moves from the bottom edge to about
		   a third of the screen, so it is complete before it is read. */
		.nortia-thread--draw::after {
			animation: nortia-thread-draw linear both;
			animation-timeline: --nortia-thread;
			animation-range: entry 0% cover 35%;
		}
	}
}

@media (min-width: 48rem) {
	.nortia-thread {
		--thread-length: min(100%, 11rem);
	}

	@supports (animation-timeline: view()) {
		@media (prefers-reduced-motion: no-preference) {
			/* Larger screens: a slightly longer, calmer stroke. */
			.nortia-thread--draw::after {
				animation-range: entry 20% cover 50%;
			}
		}
	}
}
