/**
 * Sezione competenze: accordion e figure animate.
 *
 * @package nicole-michielin
 */

/*--------------------------------------------------------------
# Impianto
--------------------------------------------------------------*/

.skills {
	/* Stesso respiro delle altre sezioni: comprimerla per farla stare in
	   una schermata la faceva sembrare un'appendice di quella prima. */
	display: flex;
	flex-direction: column;
	justify-content: center;
}

.skills__grid {
	display: grid;
	/* L'accordion sta sul 57% e la figura prende il resto: a sezione intera
	   le quattro voci diventerebbero righe lunghissime da leggere. */
	grid-template-columns: minmax(0, 57fr) minmax(0, 43fr);
	gap: clamp(1.5rem, 4vw, 4rem);
	align-items: center;
}

@media (max-width: 61.99rem) {
	.skills__grid {
		grid-template-columns: minmax(0, 1fr);
	}

	/* Su schermo stretto la figura non sta a fianco: entra nel pannello,
	   sotto il testo che illustra. */
	.skills__figure {
		display: none;
	}
}

@media (min-width: 62rem) {
	.skill__figure-inline {
		display: none;
	}
}

/*--------------------------------------------------------------
# Accordion
--------------------------------------------------------------*/

.skills__list {
	border-top: 1px solid var(--line-strong);
}

.skill {
	border-bottom: 1px solid var(--line);
}

.skill__heading {
	margin: 0;
	font-family: var(--sans);
	font-size: inherit;
	font-weight: inherit;
	letter-spacing: normal;
	line-height: inherit;
}

.skill__trigger {
	display: flex;
	align-items: center;
	gap: clamp(0.75rem, 2vw, 1.25rem);
	width: 100%;
	min-height: 56px;
	padding: 0.9rem 0;
	background: none;
	border: 0;
	text-align: left;
	cursor: pointer;
	color: var(--ink);
	transition: color var(--speed) var(--ease);
}

.skill__trigger:hover {
	color: var(--accent);
}

.skill__trigger:focus-visible {
	outline: 3px solid var(--accent);
	outline-offset: 4px;
	border-radius: 4px;
}

.skill__num {
	flex: none;
	font-family: var(--mono);
	font-size: 0.8125rem;
	color: var(--accent);
}

.skill__name {
	flex: 1;
	font-family: var(--serif);
	font-weight: 400;
	font-variation-settings: "opsz" 90, "SOFT" 40, "WONK" 1;
	font-size: clamp(1.375rem, 1.1rem + 1.1vw, 2rem);
	line-height: 1.1;
	letter-spacing: -0.015em;
}

/* La freccia è disegnata, non un carattere: resta nitida a ogni misura e
   non dipende da un font di icone. È decorativa, quindi aria-hidden. */
.skill__chevron {
	flex: none;
	width: 0.7rem;
	height: 0.7rem;
	border-right: 2px solid currentColor;
	border-bottom: 2px solid currentColor;
	transform: rotate(45deg) translate(-0.15rem, -0.15rem);
	transition: transform var(--speed) var(--ease);
	opacity: 0.7;
}

.skill__trigger[aria-expanded="true"] {
	color: var(--accent);
}

.skill__trigger[aria-expanded="true"] .skill__chevron {
	transform: rotate(-135deg) translate(-0.2rem, -0.2rem);
}

/*
 * L'altezza è animata in pixel, impostati dal JavaScript sul momento.
 *
 * La via elegante sarebbe transire grid-template-rows da 0fr a 1fr, ma
 * quella frazione non si risolve durante l'interpolazione e il pannello
 * resta alto zero anche da aperto: l'ho misurato, non dedotto. In pixel
 * funziona ovunque, e a transizione finita il JavaScript rimette l'altezza
 * automatica, così il pannello si adatta se il contenuto cambia.
 *
 * Per chiudere non si usa l'attributo hidden sovrascritto da display: un
 * pannello così resta nella lettura degli screen reader e nell'ordine di
 * tabulazione. Si usa visibility, applicata a transizione finita, che
 * toglie davvero il contenuto dall'albero di accessibilità.
 */
.skill__panel {
	overflow: hidden;
}

.skill__panel.is-closed {
	height: 0;
}

.skill__panel-inner {
	visibility: visible;
}

/* Il contenuto chiuso esce dall'albero di accessibilità e dall'ordine di
   tabulazione. Durante l'animazione resta visibile, altrimenti sparirebbe
   di colpo prima che il riquadro si sia chiuso. */
.skill__panel.is-closed .skill__panel-inner {
	visibility: hidden;
}

.skill__panel.is-animating .skill__panel-inner {
	visibility: visible;
}

.skill__text {
	padding-bottom: 0.75rem;
	color: var(--muted);
	font-size: 1.0625rem;
	line-height: 1.55;
	max-width: 54ch;
}

.skill__panel .chips {
	padding-bottom: 1.1rem;
}

.skill__figure-inline {
	padding-bottom: 1.25rem;
	max-width: 22rem;
}

/*--------------------------------------------------------------
# Figura
--------------------------------------------------------------*/

.skills__figure {
	position: relative;
	display: grid;
}

/* Le quattro figure stanno sovrapposte nella stessa cella: cambiano in
   dissolvenza senza che il riquadro cambi altezza a ogni voce. */
.skills__frame {
	grid-area: 1 / 1;
	opacity: 0;
	visibility: hidden;
	transform: translateY(0.5rem);
	transition: opacity 320ms var(--ease), transform 320ms var(--ease), visibility 320ms;
}

.skills__frame.is-current {
	opacity: 1;
	visibility: visible;
	transform: none;
}

.fig {
	display: block;
	width: 100%;
	height: auto;
	overflow: visible;
}

/*--------------------------------------------------------------
# Linguaggio comune delle figure
--------------------------------------------------------------*/

.fig__path {
	fill: none;
	stroke: var(--line-strong);
	stroke-width: 2.5;
	stroke-linecap: round;
}

.fig__path--clean {
	stroke: var(--accent);
	stroke-dasharray: 4 10;
	stroke-width: 3;
}

.fig__node {
	fill: var(--paper-2);
	stroke: var(--ink);
	stroke-width: 2.5;
}

.fig__node--end {
	fill: var(--ink);
}

.fig__chip,
.fig__field,
.fig__page,
.fig__banner,
.fig__built-card {
	fill: rgba(255, 255, 255, 0.75);
	stroke: var(--line-strong);
	stroke-width: 2;
}

.fig__label,
.fig__line {
	fill: var(--ink);
}

.fig__line--dim {
	fill: var(--line-strong);
}

.fig__button,
.fig__accept,
.fig__built-cta {
	fill: var(--ink);
}

/*--------------------------------------------------------------
# UX: dai percorsi aggrovigliati alla sequenza
--------------------------------------------------------------*/

/*
 * Il primo stato è visibile da subito e il secondo parte con un ritardo
 * negativo, cioè già a metà del proprio ciclo, dove è trasparente. Con un
 * ritardo positivo la figura restava vuota per il primo mezzo secondo, e
 * un riquadro che si apre vuoto sembra rotto.
 */
.fig__stage {
	animation: nm-fig-stage 9s var(--ease) infinite;
}

.fig__stage--a {
	opacity: 1;
	animation-delay: 0s;
}

.fig__stage--b {
	opacity: 0;
	animation-delay: -4.5s;
}

@keyframes nm-fig-stage {
	0%, 42% { opacity: 1; }
	50%, 92% { opacity: 0; }
	100% { opacity: 1; }
}

/*--------------------------------------------------------------
# Accessibilità: il focus scende di campo in campo
--------------------------------------------------------------*/

.fig__focus {
	fill: none;
	stroke: var(--accent);
	stroke-width: 3.5;
	animation: nm-fig-focus 8s steps(1, end) infinite;
}

@keyframes nm-fig-focus {
	0%, 24% { transform: translateY(0); height: 52px; }
	25%, 49% { transform: translateY(76px); height: 52px; }
	50%, 74% { transform: translateY(152px); height: 52px; }
	75%, 100% { transform: translateY(222px); height: 46px; }
}

.fig__key rect {
	fill: var(--ink);
}

.fig__key text {
	fill: var(--paper);
	font-family: var(--mono);
	font-size: 11px;
}

.fig__key {
	animation: nm-fig-key 2s var(--ease) infinite;
}

@keyframes nm-fig-key {
	0%, 70%, 100% { opacity: 0.45; transform: translateY(0); }
	12% { opacity: 1; transform: translateY(2px); }
}

/*--------------------------------------------------------------
# Compliance: «Rifiuta» si pareggia ad «Accetta»
--------------------------------------------------------------*/

.fig__reject {
	fill: var(--line-strong);
	animation: nm-fig-reject 7s var(--ease) infinite;
}

/* I valori seguono la posizione reale del pulsante nel disegno: il
   rettangolo cresce restando centrato sulla stessa riga, così l'etichetta
   non deve muoversi con lui. */
@keyframes nm-fig-reject {
	0%, 18% {
		width: 62px;
		height: 20px;
		y: 182px;
		fill: rgba(22, 21, 26, 0.16);
	}
	46%, 82% {
		width: 96px;
		height: 28px;
		y: 178px;
		fill: #16151a;
	}
	100% {
		width: 62px;
		height: 20px;
		y: 182px;
		fill: rgba(22, 21, 26, 0.16);
	}
}

.fig__tick circle {
	fill: none;
	stroke: var(--accent);
	stroke-width: 3;
}

.fig__tick path {
	fill: none;
	stroke: var(--accent);
	stroke-width: 3.5;
	stroke-linecap: round;
	stroke-linejoin: round;
}

.fig__tick {
	opacity: 0;
	animation: nm-fig-tick 7s var(--ease) infinite;
}

@keyframes nm-fig-tick {
	0%, 40% { opacity: 0; transform: scale(0.8); }
	52%, 82% { opacity: 1; transform: scale(1); }
	92%, 100% { opacity: 0; transform: scale(0.8); }
}

.fig--compliance .fig__tick {
	transform-origin: 52px 258px;
}

/*--------------------------------------------------------------
# Sviluppo: dal wireframe al costruito, senza stacco
--------------------------------------------------------------*/

.fig__wire rect {
	fill: none;
	stroke: var(--line-strong);
	stroke-width: 2;
	stroke-dasharray: 7 6;
}

.fig__wire {
	animation: nm-fig-wire 8s var(--ease) infinite;
}

@keyframes nm-fig-wire {
	0%, 34% { opacity: 1; }
	48%, 92% { opacity: 0; }
	100% { opacity: 1; }
}

.fig__built {
	opacity: 0;
	animation: nm-fig-built 8s var(--ease) infinite;
}

@keyframes nm-fig-built {
	0%, 34% { opacity: 0; }
	48%, 92% { opacity: 1; }
	100% { opacity: 0; }
}

.fig__built-bar {
	fill: var(--paper);
	stroke: var(--line-strong);
	stroke-width: 2;
}

.fig__seam {
	fill: none;
	stroke: var(--accent);
	stroke-width: 3;
	stroke-linecap: round;
	stroke-dasharray: 248;
	stroke-dashoffset: 248;
	animation: nm-fig-seam 8s var(--ease) infinite;
}

@keyframes nm-fig-seam {
	0%, 20% { stroke-dashoffset: 248; }
	44%, 92% { stroke-dashoffset: 0; }
	100% { stroke-dashoffset: 248; }
}

/*--------------------------------------------------------------
# Chi ha chiesto meno animazioni non ne vede nessuna
#
# Le figure restano, ferme sullo stato finale: quello che conta è il
# risultato, non il passaggio. WCAG 2.3.3
--------------------------------------------------------------*/

@media (prefers-reduced-motion: reduce) {
	.fig__stage,
	.fig__focus,
	.fig__key,
	.fig__reject,
	.fig__tick,
	.fig__wire,
	.fig__built,
	.fig__seam {
		animation: none;
	}

	.fig__stage--a,
	.fig__wire {
		opacity: 0 !important;
	}

	.fig__stage--b,
	.fig__built,
	.fig__tick {
		opacity: 1 !important;
	}

	.fig__focus {
		transform: translateY(152px);
	}

	.fig__reject {
		width: 96px;
		height: 28px;
		y: 178px;
		fill: #16151a;
	}

	.fig__seam {
		stroke-dashoffset: 0;
	}

	.skill__panel {
		transition: none;
	}
}

/*--------------------------------------------------------------
# Cornice della figura
#
# Senza una cornice il disegno galleggia nel vuoto e la colonna sembra
# incompiuta. Il riquadro gli dà un piano su cui stare, e l'ombra lo
# stacca dal fondo della sezione: è lo stesso espediente delle schermate
# nei casi studio.
--------------------------------------------------------------*/

.skills__figure {
	position: relative;
	padding: clamp(1.25rem, 2.5vw, 2rem);
	background-color: rgba(255, 255, 255, 0.58);
	border: 1px solid var(--line);
	border-radius: var(--radius-l);
	box-shadow: 0 32px 60px -40px rgba(22, 21, 26, 0.45);
	aspect-ratio: 4 / 3;
	align-content: center;
}

.skills__frame {
	display: flex;
	align-items: center;
}

.skill__figure-inline .fig {
	padding: 1rem;
	background-color: rgba(255, 255, 255, 0.58);
	border: 1px solid var(--line);
	border-radius: var(--radius);
}

/*--------------------------------------------------------------
# Elementi della figura UX
--------------------------------------------------------------*/

.fig__block {
	fill: rgba(255, 255, 255, 0.8);
	stroke: var(--line-strong);
	stroke-width: 2;
}

.fig__block--solid {
	fill: rgba(255, 255, 255, 0.95);
	stroke: var(--line);
}

.fig__hero {
	fill: var(--paper-2);
	stroke: var(--accent);
	stroke-width: 2.5;
}

.fig__cta {
	fill: var(--accent);
}

.fig__line--invert {
	fill: var(--paper);
}

.fig__scribble {
	fill: none;
	stroke: var(--line-strong);
	stroke-width: 2.5;
	stroke-linecap: round;
	stroke-dasharray: 5 7;
}

.fig__order circle {
	fill: var(--ink);
}

.fig__order text {
	fill: var(--paper);
	font-family: var(--mono);
	font-size: 13px;
	font-weight: 500;
}

/*--------------------------------------------------------------
# Scritte dentro le figure
#
# Senza, il disegno è una fila di rettangoli e chi guarda deve indovinare
# cosa sta vedendo. Sono testo SVG vero, quindi scalano col resto e non
# diventano sfocate.
#
# Le figure restano aria-hidden: queste parole servono agli occhi, e la
# stessa cosa è scritta per esteso nel pannello dell'accordion accanto.
--------------------------------------------------------------*/

.fig__cap {
	fill: var(--muted);
	font-family: var(--mono);
	font-size: 12px;
	letter-spacing: 0.04em;
	text-transform: uppercase;
}

.fig__cap--bad {
	fill: #9a3412;
}

.fig__cap--good {
	fill: #1f5c54;
}

/* La nota in fondo è una frase, non un'etichetta: niente maiuscoletto. */
.fig__cap--note {
	font-family: var(--sans);
	font-size: 12.5px;
	letter-spacing: 0;
	text-transform: none;
	fill: var(--muted);
}

/* Testo che sta dentro l'interfaccia disegnata. */
.fig__ui {
	fill: var(--ink);
	font-family: var(--sans);
	font-size: 15px;
	font-weight: 600;
}

.fig__ui--sm {
	font-size: 12.5px;
	font-weight: 600;
}

.fig__ui--invert {
	fill: var(--paper);
}

/* L'etichetta del rifiuto segue il pulsante: pallida e piccola all'inizio,
   piena e della misura giusta quando i due si pareggiano. */
.fig__reject-label {
	font-family: var(--sans);
	font-size: 11px;
	font-weight: 600;
	fill: rgba(22, 21, 26, 0.38);
	animation: nm-fig-reject-label 7s var(--ease) infinite;
}

@keyframes nm-fig-reject-label {
	0%, 18% { fill: rgba(22, 21, 26, 0.38); font-size: 11px; }
	46%, 82% { fill: #f2ede4; font-size: 12.5px; }
	100% { fill: rgba(22, 21, 26, 0.38); font-size: 11px; }
}

.fig__tick-label {
	opacity: 0;
	animation: nm-fig-tick 7s var(--ease) infinite;
}

@media (prefers-reduced-motion: reduce) {
	.fig__reject-label {
		animation: none;
		fill: #f2ede4;
		font-size: 12.5px;
	}

	.fig__tick-label {
		animation: none;
		opacity: 1;
	}
}
