/**
 * Inspired by The Monospace Web by Oskar Wickström
 * https://github.com/owickstrom/the-monospace-web
 * Adapted for Giuliano Hena portfolio
 **/
@import url('https://fonts.cdnfonts.com/css/jetbrains-mono-2');

:root {
  --font-family: "JetBrains Mono", monospace;
  --line-height: 1.20rem;
  --border-thickness: 2px;
  
  --text-color-light: #000;
  --text-color-alt-light: #666;
  --background-color-light: #fff;
  --background-color-alt-light: #eee;
  
  --text-color-dark: #fff;
  --text-color-alt-dark: #aaa;
  --background-color-dark: #000;
  --background-color-alt-dark: #111;

  --font-weight-normal: 500;
  --font-weight-medium: 600;
  --font-weight-bold: 800;

  /* Default to light theme */
  --text-color: var(--text-color-light);
  --text-color-alt: var(--text-color-alt-light);
  --background-color: var(--background-color-light);
  --background-color-alt: var(--background-color-alt-light);

  font-family: var(--font-family);
  font-optical-sizing: auto;
  font-weight: var(--font-weight-normal);
  font-style: normal;
  font-variant-numeric: tabular-nums lining-nums;
  font-size: 16px;
}

/* Dark mode via system preference */
@media (prefers-color-scheme: dark) {
  :root:not(.light-mode) {
    --text-color: var(--text-color-dark);
    --text-color-alt: var(--text-color-alt-dark);
    --background-color: var(--background-color-dark);
    --background-color-alt: var(--background-color-alt-dark);
  }
}

/* Dark mode override via class */
html.dark-mode {
  --text-color: var(--text-color-dark);
  --text-color-alt: var(--text-color-alt-dark);
  --background-color: var(--background-color-dark);
  --background-color-alt: var(--background-color-alt-dark);
}

* {
  box-sizing: border-box;
}

* + * {
  margin-top: var(--line-height);
}

/* Reset margin for header card elements */
.header-card * {
  margin-top: 0;
  --line-height: 0rem; /* No line-height spacing for header */
}

.header-card .hero .title + .subtitle {
  margin-top: 0.3rem; /* Fixed margin between title and subtitle */
}

html {
  display: flex;
  width: 100%;
  margin: 0;
  padding: 0;
  flex-direction: column;
  align-items: center;
  background: var(--background-color);
  color: var(--text-color);
}

body {
  position: relative;
  width: 100%;
  margin: 0;
  padding: var(--line-height) 2ch;
  max-width: calc(min(80ch, round(down, 100%, 1ch)));
  line-height: var(--line-height);
  overflow-x: hidden;
}

@media screen and (max-width: 480px) {
  :root {
    font-size: 14px;
  }
  body {
    padding: var(--line-height) 1ch;
  }
}

/* Headers */
h1, h2, h3, h4, h5, h6 {
  font-weight: var(--font-weight-bold);
  margin: calc(var(--line-height) * 2) 0 var(--line-height);
  line-height: var(--line-height);
}

h1 {
  font-size: 2rem;
  line-height: calc(2 * var(--line-height));
  margin-bottom: calc(var(--line-height) * 2);
  text-transform: uppercase;
  margin-top: 0;
}

h2 {
  font-size: 1rem;
  text-transform: uppercase;
  margin-top: calc(var(--line-height) * 2);
}

/* Header card styling - simple flexbox approach */
.header-card {
  max-width: calc(min(80ch, round(down, 100%, 1ch)));
  margin: 0 auto calc(var(--line-height) * 2) auto;
  border: var(--border-thickness) solid var(--text-color);
  display: flex;
}

/* Hero section (left side) */
.hero {
  flex: 1;
  padding: 0.8rem 2ch;
  border-right: var(--border-thickness) solid var(--text-color);
}

.hero .title {
  font-weight: var(--font-weight-bold);
  font-size: 2rem;
  line-height: 2.2rem;
  margin: 0;
  text-transform: uppercase;
}

.hero .subtitle {
  font-style: italic;
  color: var(--text-color-alt);
  font-weight: var(--font-weight-medium);
  margin: 0;
  font-size: 1rem;
  line-height: 1.2rem;
}

/* Sidebar (right side) */
.side {
  width: 25ch;
  display: flex;
  flex-direction: column;
}

.side-row {
  display: flex;
  min-height: 2.4rem;
}

.side-row + .side-row {
  border-top: var(--border-thickness) solid var(--text-color);
}

.cell {
  display: flex;
  align-items: center;
  padding: 0.4rem 0.8ch;
  font-size: 0.85rem;
  line-height: 1rem;
}

.cell.label {
  flex: 1;
  font-weight: var(--font-weight-medium);
  text-transform: uppercase;
  color: var(--text-color-alt);
  border-right: var(--border-thickness) solid var(--text-color);
}

.cell.value {
  flex: 1.2;
  justify-content: flex-end;
  font-weight: var(--font-weight-bold);
}

.cell button {
  background: var(--background-color);
  border: 1px solid var(--text-color-alt);
  color: var(--text-color);
  padding: 0.2em 0.6em;
  cursor: pointer;
  font-family: inherit;
  font-size: inherit;
  font-weight: var(--font-weight-medium);
  text-transform: uppercase;
  min-width: 3ch;
}

.cell button:hover {
  background: var(--background-color-alt);
  border-color: var(--text-color);
}

.cell button:active {
  transform: translate(1px, 1px);
}

/* Responsive header */
@media (max-width: 900px) {
  .header-card {
    flex-direction: column;
  }
  .hero {
    border-right: none;
    border-bottom: var(--border-thickness) solid var(--text-color);
  }
  .side {
    width: auto;
  }
}

/* Table of Contents */
#toc {
  margin: calc(var(--line-height) * 2) 0;
}

#toc h2 {
  font-size: 1rem;
  font-weight: var(--font-weight-bold);
  text-transform: uppercase;
  margin-bottom: var(--line-height);
}

#toc ul {
  list-style-type: square;
  padding-left: 2ch;
  margin: 0;
}

#toc li {
  margin-bottom: 0.2rem;
}

#toc a {
  color: var(--text-color);
  text-decoration: underline;
  text-decoration-thickness: var(--border-thickness);
  font-weight: var(--font-weight-medium);
}

#toc a:hover {
  color: var(--text-color-alt);
}

/* Links */
a {
  color: var(--text-color);
  text-decoration-thickness: var(--border-thickness);
}

a:link, a:visited {
  color: var(--text-color);
}

/* Paragraphs */
p {
  margin-bottom: var(--line-height);
  word-break: break-word;
  word-wrap: break-word;
  hyphens: auto;
}

/* Typography */
strong {
  font-weight: var(--font-weight-bold);
}

em {
  font-style: italic;
}

code {
  font-weight: var(--font-weight-medium);
  font-family: var(--font-family);
}

/* Sections */
section {
  margin: calc(var(--line-height) * 3) 0;
}

section:first-child {
  margin-top: 0;
}

.skill-item {
  margin: var(--line-height) 0;
  font-weight: var(--font-weight-medium);
}

.project {
  margin: calc(var(--line-height) * 2) 0;
  border-left: calc(var(--border-thickness) * 2) solid var(--text-color-alt);
  padding-left: 2ch;
}

.project h3 {
  margin-top: 0;
  margin-bottom: var(--line-height);
  font-weight: var(--font-weight-bold);
}

.project h3 a {
  text-decoration: none;
  font-weight: var(--font-weight-bold);
}

.project h3 a:hover {
  text-decoration: underline;
  text-decoration-thickness: var(--border-thickness);
}

.project p {
  color: var(--text-color-alt);
  margin: 0;
}

/* Footer */
footer {
  margin-top: calc(var(--line-height) * 4);
  text-align: center;
  color: var(--text-color-alt);
  font-weight: var(--font-weight-medium);
}

/* Pre and code blocks */
pre {
  white-space: pre;
  overflow-x: auto;
  margin: var(--line-height) 0;
  overflow-y: hidden;
  font-family: var(--font-family);
}

/* Remove default margins for specific elements */
nav, header, footer, section, main {
  margin-top: 0;
}

/* Responsive adjustments */
@media screen and (max-width: 768px) {  
  .project {
    padding-left: 1ch;
  }
  
  .header .subtitle {
    font-size: 0.9em;
  }
}