@use "mixins";

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

html {
  font-family: var(--ply-font-body, sans-serif);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  @include mixins.square;
}

html,
body,
div,
span,
object,
iframe,
p,
blockquote,
pre,
a,
abbr,
acronym,
address,
big,
cite,
code,
del,
dfn,
em,
img,
ins,
kbd,
q,
s,
samp,
small,
strike,
strong,
sub,
sup,
tt,
var,
b,
u,
i,
center,
dl,
dt,
dd,
ol,
ul,
li,
fieldset,
form,
label,
legend,
table,
caption,
tbody,
tfoot,
thead,
tr,
th,
td,
article,
aside,
canvas,
details,
embed,
figure,
figcaption,
footer,
header,
hgroup,
menu,
nav,
output,
ruby,
section,
summary,
time,
mark,
audio,
video,
h1,
h2,
h3,
h4,
h5,
h6 {
  margin: 0;
  padding: 0;
  border: 0;
  outline: 0;
  font-size: 100%;
  vertical-align: baseline;
  background: transparent;
}

a:active,
a:hover {
    outline: 0;
}

/* Visible focus for keyboard navigation */
a:focus-visible,
button:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
    outline: 2px solid var(--ply-color-focus, #0f62fe);
    outline-offset: 2px;
}

article,
aside,
details,
figcaption,
figure,
footer,
header,
hgroup,
main,
nav,
section,
embed,
object,
iframe,
audio,
video,
canvas,
progress,
meter,
output,
textarea {
  display: block;
}

audio:not([controls]) {
    display: none;
    height: 0;
}

/* To prevent some browsers from inserting quotes on q and p */
blockquote,
q {
  quotes: none;
}
blockquote p:before,
blockquote p:after,
q:before,
q:after {
  content: '';
  content: none;
}

/* Table reset */
table {
  border-collapse: collapse;
  border-spacing: 0;
}
caption,
th,
td {
  text-align: left;
  vertical-align: top;
}
thead th,
thead td {
  font-weight: bold;
  vertical-align: bottom;
}

/* Image inside */
a img,
th img,
td img {
  vertical-align: top;
}

button,
input,
select,
textarea {
  margin: 0;
}
textarea {
  overflow: auto;
  vertical-align: top;
  resize: vertical;
}

/* Normalize buttons in IE */
button {
  width: auto;
  overflow: visible;
}

/* Hand cursor on clickable controls */
input[type="reset"],
input[type="submit"],
input[type="file"],
input[type="radio"],
input[type="checkbox"],
select,
button {
  cursor: pointer;
}


/* Trick with vertical align for radio and checkbox  */
input[type="radio"],
input[type="checkbox"] {
  font-size: 110%;
  position: relative;
  top: -1px;
  margin-right: 3px;
}

/* Normalize search fields */
input[type="search"] {
  appearance: textfield;
}
input[type="search"]::-webkit-search-decoration,
input[type="search"]::-webkit-search-cancel-button {
  appearance: none;
}

/* Normalize horizontal line */
hr {
  display: block;
  height: 1px;
  border: 0;
  border-top: 1px solid var(--ply-border-color, #ddd);
}

/* Responsive media */
img,
video,
audio,
embed,
object {
  max-width: 100%;
}
img,
video,
embed,
object {
  height: auto;
}
embed,
object {
    height: 100%;
}
img {
  vertical-align: middle;
}

/* Native <details>/<summary> — Swiss/Modernist accordion */
details {
  border: 1px solid var(--ply-border-color, #e0e0e0);
  border-radius: var(--ply-border-radius);
  padding: 0.75rem 1rem;
  margin-bottom: 1.5rem;
}

summary {
  cursor: pointer;
  font-weight: 600;
  padding: 0.25rem 0;
  list-style: none;
  display: flex;
  align-items: center;

  &::marker,
  &::-webkit-details-marker {
    display: none;
  }

  // Caret sits on the right and rotates when open. Drawn with borders (symmetric
  // bounding box) so the 180° rotation pivots cleanly with no vertical shift.
  &::after {
    content: '';
    flex: none;
    margin-left: auto;
    width: 0;
    height: 0;
    border-left: 0.3em solid transparent;
    border-right: 0.3em solid transparent;
    border-top: 0.35em solid var(--ply-color-secondary);
    transition: transform 0.15s ease;
  }
}

details[open] > summary::after {
  transform: rotate(180deg);
}

details[open] > summary {
  margin-bottom: 0.75rem;
  border-bottom: 1px solid var(--ply-border-color, #e0e0e0);
  padding-bottom: 0.75rem;
}

/* Native <dialog> — modal styling */
dialog {
  border: none;
  border-radius: var(--ply-border-radius);
  padding: 1.5rem;
  max-width: 32rem;
  width: 90%;
  box-shadow: var(--ply-shadow-3, 0 4px 24px rgba(0, 0, 0, 0.15));
  background: var(--ply-bg-surface, #ffffff);
  color: var(--ply-color-body, #161616);

  &::backdrop {
    background: rgba(0, 0, 0, 0.5);
  }
}

/* Native <progress> and <meter> */
progress {
  appearance: none;
  width: 100%;
  height: 0.5rem;
  border: none;
  border-radius: var(--ply-border-radius);
  background: var(--ply-bg-muted, #e0e0e0);
  margin-bottom: 1.5rem;

  &::-webkit-progress-bar {
    background: var(--ply-bg-muted, #e0e0e0);
    border-radius: var(--ply-border-radius);
  }

  &::-webkit-progress-value {
    background: var(--ply-color-link, #0f62fe);
    border-radius: var(--ply-border-radius);
  }

  &::-moz-progress-bar {
    background: var(--ply-color-link, #0f62fe);
    border-radius: var(--ply-border-radius);
  }
}

meter {
  appearance: none;
  width: 100%;
  height: 0.5rem;
  border: none;
  border-radius: var(--ply-border-radius);
  background: var(--ply-bg-muted, #e0e0e0);
  margin-bottom: 1.5rem;
}

/* Respect reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}