/* ==========================================================================
   Portfolio theme — warm, editorial, a bit hand-made.
   Tailwind (CDN) handles layout utilities; this file holds colours, type,
   buttons, the project rows and the motion.
   ========================================================================== */

/* ---------- Colour tokens ---------- */
:root {
	--bg: #f3eee4;
	--bg-alt: #ebe4d5;
	--text: #1d1b17;
	--muted: #675f52;
	--rule: #d6cdb9;
	--accent: #c2410c;
	--accent-ink: #ffffff;
	--mark: rgba(194, 65, 12, 0.2);
	--paper: #faf7f0;
	--grain-opacity: 0.07;
}

.dark {
	--bg: #151412;
	--bg-alt: #1c1a17;
	--text: #f0eadc;
	--muted: #a0988a;
	--rule: #322f29;
	--accent: #ff8a4c;
	--accent-ink: #151412;
	--mark: rgba(255, 138, 76, 0.26);
	--paper: #1d1b18;
	--grain-opacity: 0.09;
}

/* ---------- Base ---------- */
[hidden] {
	display: none !important;
}

html {
    scroll-behavior: auto;
    -webkit-text-size-adjust: 100%;
    background-color: var(--bg);
}

body {
    font-family: 'DM Sans', 'Segoe UI', system-ui, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
    transition: background-color 0.3s ease, color 0.3s ease;
    overflow-x: clip;
}

/* paper grain */
body::before {
	content: '';
	position: fixed;
	inset: 0;
	z-index: 90;
	pointer-events: none;
	opacity: var(--grain-opacity);
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.9 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

h1,
h2,
h3,
.serif {
	font-family: 'Fraunces', Georgia, 'Times New Roman', serif;
	font-optical-sizing: auto;
}

.mono {
	font-family: 'DM Mono', ui-monospace, 'Cascadia Code', Consolas, monospace;
}

::selection {
	background: var(--accent);
	color: var(--accent-ink);
}

:focus-visible {
	outline: 2px dashed var(--accent);
	outline-offset: 4px;
}

html {
	scrollbar-width: thin;
	scrollbar-color: var(--muted) var(--bg);
}

.skip-link {
	position: fixed;
	left: 1rem;
	top: -4rem;
	z-index: 100;
	padding: 0.6rem 1rem;
	background: var(--accent);
	color: var(--accent-ink);
	font-weight: 600;
	transition: top 0.2s ease;
}
.skip-link:focus {
	top: 1rem;
}

/* ---------- Hand-drawn touches ---------- */
.marker {
	background-image: linear-gradient(transparent 60%, var(--mark) 60%, var(--mark) 92%, transparent 92%);
	padding: 0 0.1em;
	-webkit-box-decoration-break: clone;
	box-decoration-break: clone;
}

.scribble {
	display: block;
	width: 100%;
	height: auto; /* follows the viewBox ratio so the stroke scales evenly with the text */
	color: var(--accent);
	overflow: visible;
}
.scribble path {
	fill: none;
	stroke: currentColor;
	stroke-width: 4;
	stroke-linecap: round;
	/* no vector-effect: non-scaling-stroke here - it makes the dash length use screen pixels,
	   which cut the line short whenever it was wider than ~195px (i.e. on desktop). */
}
.js .scribble path {
	stroke-dasharray: 1;
	stroke-dashoffset: 1;
	transition: stroke-dashoffset 0.9s cubic-bezier(0.65, 0, 0.35, 1) 0.45s;
}
.js .is-visible .scribble path,
.js .scribble.is-visible path {
	stroke-dashoffset: 0;
}

/* ---------- Nav ---------- */
.site-nav {
    position: sticky;
    top: 0;
    z-index: 50;
    padding-top: env(safe-area-inset-top, 0px);
    background: var(--bg);
    border-bottom: 1px solid var(--rule);
    transition: background-color 0.3s ease;
}

.nav-bar {
    background: var(--bg);
    transition: background-color 0.3s ease;
}

/* Safari status bar background fix */
.safari-top-edge {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 12px;
    z-index: 9999;
    background-color: var(--bg);
}

/* Match the website's paper grain overlay */
.safari-top-edge::after {
    content: '';
    position: absolute;
    inset: 0;
    opacity: var(--grain-opacity);
    pointer-events: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.9 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.nav-link {
	position: relative;
	display: inline-block;
	padding: 0.35rem 0;
	font-size: 0.95rem;
	font-weight: 500;
	color: var(--muted);
	transition: color 0.2s ease;
}
.nav-link::after {
	content: '';
	position: absolute;
	left: 0;
	right: 0;
	bottom: -2px;
	height: 2px;
	background: var(--accent);
	transform: scaleX(0);
	transform-origin: left;
	transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}
.nav-link:hover,
.nav-link.is-active {
	color: var(--text);
}
.nav-link:hover::after,
.nav-link.is-active::after {
	transform: scaleX(1);
}

#mobile-menu:not(.hidden) {
	animation: dropIn 0.22s ease both;
}
@keyframes dropIn {
	from { opacity: 0; transform: translateY(-6px); }
	to { opacity: 1; transform: none; }
}

#scroll-progress {
	background: var(--accent);
	transform: scaleX(0);
	transform-origin: left;
	will-change: transform;
}

.icon-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 2.6rem;
	height: 2.6rem;
	border: 1.5px solid var(--text);
	border-radius: 999px;
	color: var(--text);
	background: transparent;
	cursor: pointer;
	transition: background-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}
.icon-btn:hover {
	background: var(--text);
	color: var(--bg);
}
.icon-btn svg {
	width: 1.15rem;
	height: 1.15rem;
}

/* ---------- Buttons ---------- */
.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.55rem;
	padding: 0.8rem 1.4rem;
	border: 2px solid var(--text);
	border-radius: 0.7rem;
	font-weight: 600;
	font-size: 0.95rem;
	line-height: 1.2;
	cursor: pointer;
	transition: transform 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}
.btn:hover {
	transform: translate(-3px, -3px);
	box-shadow: 4px 4px 0 var(--text);
}
.btn:active {
	transform: translate(0, 0);
	box-shadow: 0 0 0 var(--text);
}
.btn-primary {
	background: var(--accent);
	color: var(--accent-ink);
}
.btn-plain {
	background: transparent;
	color: var(--text);
}

.link {
	background-image: linear-gradient(var(--accent), var(--accent));
	background-repeat: no-repeat;
	background-size: 100% 2px;
	background-position: 0 100%;
	padding-bottom: 2px;
	transition: background-size 0.25s ease, color 0.2s ease;
}
.link:hover {
	background-size: 100% 100%;
	color: var(--accent-ink);
}

/* ---------- Hero ---------- */
.cursor {
	display: inline-block;
	width: 0.6ch;
	height: 1.05em;
	margin-left: 3px;
	vertical-align: -0.15em;
	background: var(--accent);
	animation: blink 1s steps(1) infinite;
}
@keyframes blink {
	50% { opacity: 0; }
}

.photo {
	position: relative;
	transform: rotate(-1.8deg);
	transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}
.photo::before {
	content: '';
	position: absolute;
	inset: 0;
	transform: translate(16px, 16px);
	border: 2px solid var(--text);
	border-radius: 1.1rem;
	background: var(--accent);
}
.photo:hover {
	transform: rotate(0deg);
}
.photo img {
	position: relative;
	display: block;
	width: 100%;
	aspect-ratio: 4 / 5;
	max-height: 70vh;
	object-fit: cover;
	object-position: 50% 25%;
	border: 2px solid var(--text);
	border-radius: 1.1rem;
	background: var(--bg-alt);
}

/* ---------- Sections ---------- */
.section {
	padding: 5.5rem 1.25rem;
}
@media (min-width: 640px) {
	.section { padding-left: 2rem; padding-right: 2rem; }
}

.section-grid {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: 1.5rem;
	max-width: 72rem;
	margin: 0 auto;
	padding-top: 1.5rem;
	border-top: 2px solid var(--text);
}
@media (min-width: 768px) {
	.section-grid {
		grid-template-columns: 11rem minmax(0, 1fr);
		gap: 3rem;
	}
}

.section-label {
	font-family: 'DM Mono', ui-monospace, Consolas, monospace;
	font-size: 0.85rem;
	font-weight: 500;
	letter-spacing: 0.04em;
	text-transform: lowercase;
	color: var(--accent);
}
.section-label::before {
	content: '/ ';
	color: var(--muted);
}

.lead {
	font-family: 'Fraunces', Georgia, serif;
	font-size: clamp(1.6rem, 3.6vw, 2.6rem);
	line-height: 1.25;
	font-weight: 400;
	letter-spacing: -0.01em;
}

/* ---------- Skills ---------- */
.skill-row {
	display: grid;
	gap: 0.9rem;
	padding: 1.4rem 0;
	border-top: 1px solid var(--rule);
}
.skill-row:last-child {
	border-bottom: 1px solid var(--rule);
}
@media (min-width: 640px) {
	.skill-row { grid-template-columns: 9rem 1fr; align-items: center; }
}
.skill {
	display: inline-flex;
	align-items: center;
	gap: 0.6rem;
	padding: 0.45rem 0.9rem 0.45rem 0.6rem;
	border: 1.5px solid var(--text);
	border-radius: 999px;
	font-weight: 500;
	background: var(--paper);
	transition: transform 0.2s ease, background-color 0.2s ease;
}
.skill img {
	width: 1.5rem;
	height: 1.5rem;
}
.skill:nth-child(odd):hover { transform: rotate(-2.5deg) translateY(-3px); }
.skill:nth-child(even):hover { transform: rotate(2deg) translateY(-3px); }

/* ---------- Projects ---------- */
.project {
	position: relative;
	display: grid;
	gap: 1.75rem;
	padding: 2.75rem 0;
	border-top: 1px solid var(--rule);
}
.project:first-of-type {
	border-top: 0;
	padding-top: 0.5rem;
}
@media (min-width: 900px) {
	.project { grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 2.5rem; align-items: center; }
	.project .project-text { grid-column: span 5; }
	.project .project-shot { grid-column: span 7; }
	.project:nth-of-type(even) .project-text { order: 2; }
	.project:nth-of-type(even) .project-shot { order: 1; }
}

.project-num {
	font-family: 'DM Mono', ui-monospace, Consolas, monospace;
	font-size: 0.85rem;
	color: var(--muted);
}
.project h3 {
	margin: 0.4rem 0 0.9rem;
	font-size: clamp(1.6rem, 3vw, 2.3rem);
	font-weight: 600;
	line-height: 1.12;
	letter-spacing: -0.015em;
}
.tech {
	margin-top: 1.1rem;
	font-family: 'DM Mono', ui-monospace, Consolas, monospace;
	font-size: 0.8rem;
	line-height: 1.8;
	color: var(--muted);
}

.view-detail {
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	margin-top: 1.4rem;
	font-weight: 600;
	color: var(--text);
	transition: gap 0.25s ease, color 0.2s ease;
}
.view-detail::after {
	content: '';
	position: absolute;
	inset: 0;
	z-index: 2;
}
.project:hover .view-detail {
	gap: 0.9rem;
	color: var(--accent);
}

.browser {
	overflow: hidden;
	border: 2px solid var(--text);
	border-radius: 0.9rem;
	background: var(--paper);
	transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}
.project:hover .browser {
	transform: translate(-5px, -5px);
	box-shadow: 9px 9px 0 var(--accent);
}
.browser-bar {
	display: flex;
	align-items: center;
	gap: 0.4rem;
	padding: 0.6rem 0.85rem;
	border-bottom: 2px solid var(--text);
	background: var(--bg-alt);
}
.browser-bar i {
	width: 0.6rem;
	height: 0.6rem;
	border: 1.5px solid var(--text);
	border-radius: 50%;
}
.browser-bar i:first-child { background: var(--accent); }
.browser img {
	display: block;
	width: 100%;
	aspect-ratio: 16 / 10;
	object-fit: cover;
	object-position: top;
}

/* ---------- Modal ---------- */
#project-modal:not(.hidden) {
	animation: fadeIn 0.2s ease both;
}
#project-modal:not(.hidden) #project-modal-panel {
	animation: panelIn 0.3s cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes fadeIn {
	from { opacity: 0; }
	to { opacity: 1; }
}
@keyframes panelIn {
	from { opacity: 0; transform: translateY(18px); }
	to { opacity: 1; transform: none; }
}

.modal-nav {
	position: absolute;
	top: 50%;
	z-index: 2;
	display: grid;
	place-items: center;
	width: 2.8rem;
	height: 2.8rem;
	margin-top: -1.4rem;
	border: 2px solid var(--text);
	border-radius: 50%;
	background: var(--bg);
	color: var(--text);
	font-size: 1.5rem;
	line-height: 1;
	cursor: pointer;
	transition: background-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}
.modal-nav:hover {
	background: var(--accent);
	color: var(--accent-ink);
	transform: scale(1.06);
}

.counter {
	position: absolute;
	top: 1rem;
	left: 1rem;
	z-index: 2;
	padding: 0.2rem 0.7rem;
	border: 2px solid var(--text);
	border-radius: 999px;
	background: var(--bg);
	font-family: 'DM Mono', ui-monospace, Consolas, monospace;
	font-size: 0.78rem;
}

.thumb-btn {
	flex: none;
	width: 5.2rem;
	height: 3.4rem;
	overflow: hidden;
	border: 2px solid var(--rule);
	border-radius: 0.5rem;
	opacity: 0.6;
	background: var(--bg-alt);
	cursor: pointer;
	transition: opacity 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}
.thumb-btn img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	object-position: top;
}
.thumb-btn:hover { opacity: 0.95; }
.thumb-btn.is-active {
	opacity: 1;
	border-color: var(--accent);
	transform: translateY(-2px);
}

#project-modal-image {
	transition: opacity 0.2s ease;
}

.tag {
	display: inline-block;
	padding: 0.2rem 0.65rem;
	border: 1.5px solid var(--text);
	border-radius: 999px;
	font-family: 'DM Mono', ui-monospace, Consolas, monospace;
	font-size: 0.76rem;
}

/* ---------- Contact ---------- */
.big-mail {
	display: inline-block;
	font-family: 'Fraunces', Georgia, serif;
	font-size: clamp(1.5rem, 4.6vw, 3.2rem);
	font-weight: 500;
	line-height: 1.15;
	letter-spacing: -0.015em;
	overflow-wrap: anywhere;
}

/* ---------- Scroll reveal (only when JS is running) ---------- */
.js .reveal {
	opacity: 0;
	transform: translateY(22px);
	transition:
		opacity 0.6s ease var(--d, 0ms),
		transform 0.7s cubic-bezier(0.22, 1, 0.36, 1) var(--d, 0ms);
}
.js .reveal.is-visible {
	opacity: 1;
	transform: none;
}

/* ---------- Reduced motion: keep the animations, just make them gentler ----------
   (Many Windows machines report "reduce" because system animations are off, which
   would otherwise make the whole site feel static. Nothing here is flashing or large.) */
@media (prefers-reduced-motion: reduce) {
	.cursor { animation: none; }
	.js .reveal {
		transform: translateY(10px);
		transition:
			opacity 0.45s ease var(--d, 0ms),
			transform 0.45s ease var(--d, 0ms);
	}
	.js .reveal.is-visible { transform: none; }
}

/* iPhone Safari safe-area background */
@supports (-webkit-touch-callout: none) {
    body::after {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: env(safe-area-inset-top, 0px);
        background: var(--bg);
        z-index: 49;
        pointer-events: none;
    }
}